fix: review comments batch 2

This commit is contained in:
Stavros
2026-05-05 18:54:45 +03:00
parent d47e4d3d79
commit e04980468f
9 changed files with 78 additions and 23 deletions
+9 -3
View File
@@ -73,7 +73,7 @@ type Lockdown struct {
}
type AuthServiceConfig struct {
LocalUsers []model.LocalUser
LocalUsers *[]model.LocalUser
OauthWhitelist []string
SessionExpiry int
SessionMaxLifetime int
@@ -147,6 +147,9 @@ func (auth *AuthService) CheckUserPassword(search model.UserSearch, password str
switch search.Type {
case model.UserLocal:
user := auth.GetLocalUser(search.Username)
if user == nil {
return ErrUserNotFound
}
return bcrypt.CompareHashAndPassword([]byte(user.Password), []byte(password))
case model.UserLDAP:
if auth.ldap.IsConfigured() {
@@ -169,7 +172,10 @@ func (auth *AuthService) CheckUserPassword(search model.UserSearch, password str
}
func (auth *AuthService) GetLocalUser(username string) *model.LocalUser {
for _, user := range auth.config.LocalUsers {
if auth.config.LocalUsers == nil {
return nil
}
for _, user := range *auth.config.LocalUsers {
if user.Username == username {
return &user
}
@@ -438,7 +444,7 @@ func (auth *AuthService) GetSession(ctx context.Context, uuid string) (*reposito
}
func (auth *AuthService) LocalAuthConfigured() bool {
return len(auth.config.LocalUsers) > 0
return auth.config.LocalUsers != nil && len(*auth.config.LocalUsers) > 0
}
func (auth *AuthService) LDAPAuthConfigured() bool {