π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Wire memory share into existing auth and file controllers
AmanRajSinghMourya2b6ca28c0a2d
diff --git a/server/ente/userentity/entity.go b/server/ente/userentity/entity.goindex 904b846d1a..dbfd7d6ad0 100644--- a/server/ente/userentity/entity.go+++ b/server/ente/userentity/entity.go@@ -18,11 +18,13 @@ const (CGroup EntityType = "cgroup"// SmartAlbum is a new entity type for storing smart album config dataSmartAlbum EntityType = "smart_album"+ // Memory is the entity type for memory share encryption keys+ Memory EntityType = "memory")func (et EntityType) IsValid() error {switch et {- case Location, Person, CGroup, SmartAlbum:+ case Location, Person, CGroup, SmartAlbum, Memory:return nil}return ente.NewBadRequestWithMessage(fmt.Sprintf("Invalid EntityType: %s", et))diff --git a/server/pkg/controller/file.go b/server/pkg/controller/file.goindex 6635572db1..00872ddf80 100644--- a/server/pkg/controller/file.go+++ b/server/pkg/controller/file.go@@ -460,6 +460,12 @@ func (c *FileController) DoesFileExistInCollection(ctx *gin.Context, fileID int6return nil}+// GetSignedURLForPublicFile returns a presigned URL for a file without access checking.+// The caller is responsible for verifying access before calling this method.+func (c *FileController) GetSignedURLForPublicFile(ctx *gin.Context, fileID int64, objType ente.ObjectType) (string, error) {+ return c.getSignedURLForType(ctx, fileID, objType)+}+func (c *FileController) getSignedURLForType(ctx *gin.Context, fileID int64, objType ente.ObjectType) (string, error) {if isCliRequest(ctx) {return c.getWasabiSignedUrlIfAvailable(fileID, objType)diff --git a/server/pkg/utils/auth/auth.go b/server/pkg/utils/auth/auth.goindex 83cda2274c..d4987f5fdf 100644--- a/server/pkg/utils/auth/auth.go+++ b/server/pkg/utils/auth/auth.go@@ -3,12 +3,13 @@ package authimport ("crypto/rand""encoding/base64"- "github.com/ente-io/museum/ente/cast""math/big""net/http""strconv""strings"+ "github.com/ente-io/museum/ente/cast"+"github.com/ente-io/museum/ente""github.com/ente-io/stacktrace"@@ -17,10 +18,11 @@ import ()const (- PublicAccessKey = "X-Public-Access-ID"- PublicAnonUserKey = "X-Public-Anon-User-ID"- FileLinkAccessKey = "X-Public-FileLink-Access-ID"- CastContext = "X-Cast-Context"+ PublicAccessKey = "X-Public-Access-ID"+ PublicAnonUserKey = "X-Public-Anon-User-ID"+ FileLinkAccessKey = "X-Public-FileLink-Access-ID"+ CastContext = "X-Cast-Context"+ MemoryShareAccessKey = "X-Memory-Share-Access-ID")// GenerateRandomBytes returns securely generated random bytes.@@ -159,3 +161,7 @@ func MustGetFileLinkAccessContext(c *gin.Context) *ente.FileLinkAccessContext {func GetCastCtx(c *gin.Context) cast.AuthContext {return c.MustGet(CastContext).(cast.AuthContext)}++func MustGetMemoryShareAccessContext(c *gin.Context) ente.MemoryShareAccessContext {+ return c.MustGet(MemoryShareAccessKey).(ente.MemoryShareAccessContext)+}