refactor: remove deprecated OIDC URLs and enhance logging in auth service

Signed-off-by: Noooste <83548733+Noooste@users.noreply.github.com>
This commit is contained in:
Noooste
2026-04-19 11:08:17 +02:00
parent 047a653446
commit d0040be103
5 changed files with 3 additions and 56 deletions
+3 -29
View File
@@ -1,6 +1,7 @@
package auth
import (
"Noooste/garage-ui/pkg/logger"
"context"
"crypto/subtle"
"encoding/base64"
@@ -107,35 +108,6 @@ func (a *Service) ValidateBasicAuth(username, password string) bool {
return usernameMatch && passwordMatch
}
// ParseBasicAuth parses the Authorization header for basic auth
func ParseBasicAuth(authHeader string) (username, password string, ok bool) {
if authHeader == "" {
return "", "", false
}
// Check if it's a Basic auth header
const prefix = "Basic "
if !strings.HasPrefix(authHeader, prefix) {
return "", "", false
}
// Decode base64 credentials
encoded := authHeader[len(prefix):]
decoded, err := base64.StdEncoding.DecodeString(encoded)
if err != nil {
return "", "", false
}
// Split username:password
credentials := string(decoded)
parts := strings.SplitN(credentials, ":", 2)
if len(parts) != 2 {
return "", "", false
}
return parts[0], parts[1], true
}
// GetAuthorizationURL returns the OIDC authorization URL for login
func (a *Service) GetAuthorizationURL(state string) (string, error) {
if a.oauth2Config == nil {
@@ -213,6 +185,8 @@ func (a *Service) GetUserInfo(ctx context.Context, token *oauth2.Token) (*UserIn
return nil, fmt.Errorf("failed to parse user info claims: %w", err)
}
logger.Debug().Interface("claims", claims).Msg("Extracted user info claims")
// Build user info
userInfo := &UserInfo{
Username: extractClaim(claims, a.authConfig.OIDC.UsernameAttribute),
-3
View File
@@ -57,9 +57,6 @@ auth:
# OIDC Provider URLs
issuer_url: "https://keycloak.example.com/realms/master"
auth_url: "https://keycloak.example.com/realms/master/protocol/openid-connect/auth"
token_url: "https://keycloak.example.com/realms/master/protocol/openid-connect/token"
userinfo_url: "https://keycloak.example.com/realms/master/protocol/openid-connect/userinfo"
# Token validation
skip_issuer_check: false
-3
View File
@@ -409,9 +409,6 @@ config:
- email
- profile
issuer_url: "https://auth.example.com/realms/production"
auth_url: "https://auth.example.com/realms/production/protocol/openid-connect/auth"
token_url: "https://auth.example.com/realms/production/protocol/openid-connect/token"
userinfo_url: "https://auth.example.com/realms/production/protocol/openid-connect/userinfo"
cookie_secure: true
cookie_http_only: true
cookie_same_site: "lax"
-18
View File
@@ -292,24 +292,6 @@
"pattern": "^https?://",
"default": "https://keycloak.example.com/realms/master"
},
"auth_url": {
"type": "string",
"description": "Authorization endpoint URL",
"pattern": "^https?://",
"default": "https://keycloak.example.com/realms/master/protocol/openid-connect/auth"
},
"token_url": {
"type": "string",
"description": "Token endpoint URL",
"pattern": "^https?://",
"default": "https://keycloak.example.com/realms/master/protocol/openid-connect/token"
},
"userinfo_url": {
"type": "string",
"description": "User info endpoint URL",
"pattern": "^https?://",
"default": "https://keycloak.example.com/realms/master/protocol/openid-connect/userinfo"
},
"skip_issuer_check": {
"type": "boolean",
"description": "Skip issuer validation (not recommended for production)",
-3
View File
@@ -77,9 +77,6 @@ config:
- profile
# OIDC provider endpoints
issuer_url: "https://keycloak.example.com/realms/master"
auth_url: "https://keycloak.example.com/realms/master/protocol/openid-connect/auth"
token_url: "https://keycloak.example.com/realms/master/protocol/openid-connect/token"
userinfo_url: "https://keycloak.example.com/realms/master/protocol/openid-connect/userinfo"
# Validation settings
skip_issuer_check: false
skip_expiry_check: false