Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Add endpoint to get pass-info

Neeraj Guptad9710555ea89
diff --git a/server/cmd/museum/main.go b/server/cmd/museum/main.go
index 9b22620181..1a07b58c04 100644
--- a/server/cmd/museum/main.go
+++ b/server/cmd/museum/main.go
@@ -600,6 +600,7 @@ func main() {
}
fileLinkApi.GET("/info", fileHandler.LinkInfo)
+ fileLinkApi.GET("/pass-info", fileHandler.PasswordInfo)
fileLinkApi.GET("/thumbnail", fileHandler.LinkThumbnail)
fileLinkApi.GET("/file", fileHandler.LinkFile)
fileLinkApi.POST("/verify-password", fileHandler.VerifyPassword)
diff --git a/server/pkg/api/file_link.go b/server/pkg/api/file_link.go
index fa7dc9aaae..d243a87532 100644
--- a/server/pkg/api/file_link.go
+++ b/server/pkg/api/file_link.go
@@ -37,6 +37,19 @@ func (h *FileHandler) LinkInfo(c *gin.Context) {
})
}
+func (h *FileHandler) PasswordInfo(c *gin.Context) {
+ resp, err := h.FileUrlCtrl.PassInfo(c)
+ if err != nil {
+ handler.Error(c, stacktrace.Propagate(err, ""))
+ return
+ }
+ c.JSON(http.StatusOK, gin.H{
+ "nonce": resp.Nonce,
+ "opsLimit": resp.OpsLimit,
+ "memLimit": resp.MemLimit,
+ })
+}
+
func (h *FileHandler) LinkThumbnail(c *gin.Context) {
linkCtx := auth.MustGetFileLinkAccessContext(c)
url, err := h.Controller.GetThumbnailURL(c, linkCtx.OwnerID, linkCtx.FileID)
diff --git a/server/pkg/controller/public/file_link.go b/server/pkg/controller/public/file_link.go
index dad8e139e9..be015bc719 100644
--- a/server/pkg/controller/public/file_link.go
+++ b/server/pkg/controller/public/file_link.go
@@ -115,6 +115,11 @@ func (c *FileLinkController) Info(ctx *gin.Context) (*ente.File, error) {
return c.FileRepo.GetFileAttributes(accessContext.FileID)
}
+func (c *FileLinkController) PassInfo(ctx *gin.Context) (*ente.FileLinkRow, error) {
+ accessContext := auth.MustGetFileLinkAccessContext(ctx)
+ return c.FileLinkRepo.GetFileUrlRowByFileID(ctx, accessContext.FileID)
+}
+
// VerifyPassword verifies if the user has provided correct pw hash. If yes, it returns a signed jwt token which can be
// used by the client to pass in other requests for public collection.
// Having a separate endpoint for password validation allows us to easily rate-limit the attempts for brute-force