π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Support legacy browser origins
Manav Rathic71f17fb6001
diff --git a/server/cmd/museum/main.go b/server/cmd/museum/main.goindex 36f508fb37..21b91d97d4 100644--- a/server/cmd/museum/main.go+++ b/server/cmd/museum/main.go@@ -1116,7 +1116,7 @@ func setAppDefaults() {viper.SetDefault("apps.family", "https://family.ente.io")viper.SetDefault("apps.space", "https://ente.space")viper.SetDefault("apps.legacy", "https://legacy.ente.com")- viper.SetDefault("apps.extra-origins", []string{"https://ente.com", "https://embed.ente.io", "https://cast.ente.io", "https://staff.ente.sh"})+ viper.SetDefault("apps.extra-origins", []string{"https://ente.com", "https://ente.io", "https://web.ente.io", "https://auth.ente.io", "https://locker.ente.io", "https://share.ente.io", "https://payments.ente.io", "https://embed.ente.io", "https://cast.ente.io", "https://staff.ente.sh"})viper.SetDefault("apps.custom-domain.cname", "my.ente.com")}@@ -1441,19 +1441,21 @@ func corsForOrigins(origins []string, enforce bool) gin.HandlerFunc {knownOrigins[origin] = true}}- isKnownOrigin := func(c *gin.Context, origin string) bool {+ isAllowed := func(c *gin.Context, origin string) bool {+ path := c.Request.URL.Path+ if path == "/files/count" || path == "/billing/plans/v2" {+ return true+ }if origin == "" || knownOrigins[normalizeOrigin(origin)] || network.IsLoopbackOrigin(origin) {return true}// CollectionLinkMiddleware validates custom album domains.- path := c.Request.URL.Pathreturn path == "/public-collection" || strings.HasPrefix(path, "/public-collection/")}return func(c *gin.Context) {origin := c.GetHeader("Origin")- knownOrigin := isKnownOrigin(c, origin)- if !knownOrigin {+ if !isAllowed(c, origin) {if c.Request.Method != http.MethodOptions || enforce {message := "unknown CORS origin"if enforce {diff --git a/server/cmd/museum/main_cors_test.go b/server/cmd/museum/main_cors_test.goindex efb64cd40b..272f73613b 100644--- a/server/cmd/museum/main_cors_test.go+++ b/server/cmd/museum/main_cors_test.go@@ -39,6 +39,8 @@ func TestCORS(t *testing.T) {{"private address", http.MethodGet, "/users/details", "http://192.168.1.2:3000", "api.ente.com", http.StatusNoContent, true, true, false},{"localhost lookalike", http.MethodGet, "/users/details", "http://localhost.example:3000", "api.ente.com", http.StatusNoContent, true, true, false},{"non-HTTP loopback", http.MethodGet, "/users/details", "ftp://localhost", "api.ente.com", http.StatusNoContent, true, true, false},+ {"public file count", http.MethodGet, "/files/count", "null", "api.ente.com", http.StatusNoContent, true, false, true},+ {"public billing plans", http.MethodGet, "/billing/plans/v2", "https://unknown.example", "api.ente.com", http.StatusNoContent, true, false, true},{"custom album domain", http.MethodGet, "/public-collection/info", "https://gallery.example", "api.ente.com", http.StatusNoContent, true, false, false},{"album prefix lookalike", http.MethodGet, "/public-collection-evil", "https://gallery.example", "api.ente.com", http.StatusNoContent, true, true, false},{"unknown preflight", http.MethodOptions, "/users/details", "https://unknown.example", "api.ente.com", http.StatusOK, false, false, false},@@ -114,6 +116,12 @@ func TestCORSProductionOriginsAreDefaults(t *testing.T) {"https://albums.ente.com","https://embed.ente.com","https://ente.com",+ "https://ente.io",+ "https://web.ente.io",+ "https://auth.ente.io",+ "https://locker.ente.io",+ "https://share.ente.io",+ "https://payments.ente.io","https://embed.ente.io","https://cast.ente.io","https://staff.ente.sh",diff --git a/server/configurations/local.yaml b/server/configurations/local.yamlindex 8426a6a58f..4d868ab227 100644--- a/server/configurations/local.yaml+++ b/server/configurations/local.yaml@@ -154,11 +154,7 @@ apps:legacy:# Additional trusted browser origins not represented by an app above.#- # Default is:- # - https://ente.com- # - https://embed.ente.io- # - https://cast.ente.io- # - https://staff.ente.sh+ # Default is a list of Ente domains: ente.com and older production aliases.extra-origins:# Default is true if none of photos, auth, locker or extra-origins above# are set, and false otherwise.