feature: Cleanup auth code (#444)
This commit is contained in:
parent
0283b51eca
commit
80e5b5b0c1
|
|
@ -58,12 +58,12 @@ func parseRequestMetadata(ctx context.Context, req *http.Request) metadata.MD {
|
||||||
provider = "jwt-cookie"
|
provider = "jwt-cookie"
|
||||||
}
|
}
|
||||||
|
|
||||||
if cfg.AuthHttpHeaderUsername != "" {
|
if cfg.AuthHttpHeaderUsername != "" && username == "" {
|
||||||
username, usergroup = parseHttpHeaderForAuth(req)
|
username, usergroup = parseHttpHeaderForAuth(req)
|
||||||
provider = "http-header"
|
provider = "http-header"
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(cfg.AuthOAuth2Providers) > 0 {
|
if len(cfg.AuthOAuth2Providers) > 0 && username == "" {
|
||||||
username, usergroup, sid = parseOAuth2Cookie(req)
|
username, usergroup, sid = parseOAuth2Cookie(req)
|
||||||
provider = "oauth2"
|
provider = "oauth2"
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -254,6 +254,10 @@ func parseOAuth2Cookie(r *http.Request) (string, string, string) {
|
||||||
return "", "", ""
|
return "", "", ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if cookie.Value == "" {
|
||||||
|
return "", "", ""
|
||||||
|
}
|
||||||
|
|
||||||
serverState, found := registeredStates[cookie.Value]
|
serverState, found := registeredStates[cookie.Value]
|
||||||
|
|
||||||
if !found {
|
if !found {
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ func generateWebUISettings(w http.ResponseWriter, r *http.Request) {
|
||||||
SshFoundConfig: installationinfo.Runtime.SshFoundConfig,
|
SshFoundConfig: installationinfo.Runtime.SshFoundConfig,
|
||||||
EnableCustomJs: cfg.EnableCustomJs,
|
EnableCustomJs: cfg.EnableCustomJs,
|
||||||
AuthLoginUrl: cfg.AuthLoginUrl,
|
AuthLoginUrl: cfg.AuthLoginUrl,
|
||||||
AuthLocalLogin: true,
|
AuthLocalLogin: cfg.AuthLocalUsers.Enabled,
|
||||||
AuthOAuth2Providers: buildPublicOAuth2ProvidersList(cfg),
|
AuthOAuth2Providers: buildPublicOAuth2ProvidersList(cfg),
|
||||||
AdditionalLinks: cfg.AdditionalNavigationLinks,
|
AdditionalLinks: cfg.AdditionalNavigationLinks,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue