feature: Cleanup auth code (#444)

This commit is contained in:
James Read 2024-10-19 20:33:27 +01:00 committed by GitHub
parent 0283b51eca
commit 80e5b5b0c1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 7 additions and 3 deletions

View File

@ -58,12 +58,12 @@ func parseRequestMetadata(ctx context.Context, req *http.Request) metadata.MD {
provider = "jwt-cookie"
}
if cfg.AuthHttpHeaderUsername != "" {
if cfg.AuthHttpHeaderUsername != "" && username == "" {
username, usergroup = parseHttpHeaderForAuth(req)
provider = "http-header"
}
if len(cfg.AuthOAuth2Providers) > 0 {
if len(cfg.AuthOAuth2Providers) > 0 && username == "" {
username, usergroup, sid = parseOAuth2Cookie(req)
provider = "oauth2"
}

View File

@ -254,6 +254,10 @@ func parseOAuth2Cookie(r *http.Request) (string, string, string) {
return "", "", ""
}
if cookie.Value == "" {
return "", "", ""
}
serverState, found := registeredStates[cookie.Value]
if !found {

View File

@ -142,7 +142,7 @@ func generateWebUISettings(w http.ResponseWriter, r *http.Request) {
SshFoundConfig: installationinfo.Runtime.SshFoundConfig,
EnableCustomJs: cfg.EnableCustomJs,
AuthLoginUrl: cfg.AuthLoginUrl,
AuthLocalLogin: true,
AuthLocalLogin: cfg.AuthLocalUsers.Enabled,
AuthOAuth2Providers: buildPublicOAuth2ProvidersList(cfg),
AdditionalLinks: cfg.AdditionalNavigationLinks,
})