[server] Document the internal.admin flag
Complements https://github.com/ente-io/ente/pull/4228
This commit is contained in:
@@ -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
|
||||
#
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user