Skip to content

armgit / ente

Public Imported from GitHub
0

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

[server] Document the internal.admin flag

Manav Rathic6872d2d3510
diff --git a/server/configurations/local.yaml b/server/configurations/local.yaml
index 5fd96d3ce8..463e3f86da 100644
--- a/server/configurations/local.yaml
+++ b/server/configurations/local.yaml
@@ -317,6 +317,10 @@ internal:
# List of user IDs that can use the admin API endpoints.
# If this is not set, as a fallback, the first user is considered an admin.
admins: []
+ # In case there is a single admin, it can be alternatively specified by as
+ # the "admin" instead of "admins". This can be useful e.g. when wishing to
+ # pass the admin as an environment variable.
+ admin:
# Replication config
#
diff --git a/server/pkg/middleware/auth.go b/server/pkg/middleware/auth.go
index 9b5797cc98..6b1b191b1a 100644
--- a/server/pkg/middleware/auth.go
+++ b/server/pkg/middleware/auth.go
@@ -91,14 +91,16 @@ func (m *AuthMiddleware) AdminAuthMiddleware() gin.HandlerFunc {
return
}
}
- // if no admins are set, then check if the user is first user in the system
+ // The config allows alternatively specifying a singular admin ID to
+ // workaround Viper issues in passing env vars for an int slice.
if len(admins) == 0 {
- // Fallback for specifying a singular admin ID when encountering https://github.com/spf13/viper/issues/1611
if viper.GetInt("internal.admin") == userId {
c.Next()
return
}
-
+ }
+ // if no admins are set, then check if the user is first user in the system
+ if len(admins) == 0 {
id, err := m.UserAuthRepo.GetMinUserID()
if err != nil && id == userID {
c.Next()