feat: validate OAUTH2_PROVIDER value
This commit is contained in:
parent
9b8eabf036
commit
cc94ab704a
1 changed files with 17 additions and 11 deletions
|
@ -89,6 +89,23 @@ func Parse() {
|
||||||
printErrorAndExit(err)
|
printErrorAndExit(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if oauth2Provider := config.Opts.OAuth2Provider(); oauth2Provider != "" {
|
||||||
|
if oauth2Provider != "oidc" && oauth2Provider != "google" {
|
||||||
|
printErrorAndExit(fmt.Errorf(`unsupported OAuth2 provider: %q (Possible values are "google" or "oidc")`, oauth2Provider))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if config.Opts.DisableLocalAuth() {
|
||||||
|
switch {
|
||||||
|
case config.Opts.OAuth2Provider() == "" && config.Opts.AuthProxyHeader() == "":
|
||||||
|
printErrorAndExit(errors.New("DISABLE_LOCAL_AUTH is enabled but neither OAUTH2_PROVIDER nor AUTH_PROXY_HEADER is not set. Please enable at least one authentication source"))
|
||||||
|
case config.Opts.OAuth2Provider() != "" && !config.Opts.IsOAuth2UserCreationAllowed():
|
||||||
|
printErrorAndExit(errors.New("DISABLE_LOCAL_AUTH is enabled and an OAUTH2_PROVIDER is configured, but OAUTH2_USER_CREATION is not enabled"))
|
||||||
|
case config.Opts.AuthProxyHeader() != "" && !config.Opts.IsAuthProxyUserCreationAllowed():
|
||||||
|
printErrorAndExit(errors.New("DISABLE_LOCAL_AUTH is enabled and an AUTH_PROXY_HEADER is configured, but AUTH_PROXY_USER_CREATION is not enabled"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if flagConfigDump {
|
if flagConfigDump {
|
||||||
fmt.Print(config.Opts)
|
fmt.Print(config.Opts)
|
||||||
return
|
return
|
||||||
|
@ -226,17 +243,6 @@ func Parse() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if config.Opts.DisableLocalAuth() {
|
|
||||||
switch {
|
|
||||||
case config.Opts.OAuth2Provider() == "" && config.Opts.AuthProxyHeader() == "":
|
|
||||||
printErrorAndExit(errors.New("DISABLE_LOCAL_AUTH is enabled but neither OAUTH2_PROVIDER nor AUTH_PROXY_HEADER is not set. Please enable at least one authentication source"))
|
|
||||||
case config.Opts.OAuth2Provider() != "" && !config.Opts.IsOAuth2UserCreationAllowed():
|
|
||||||
printErrorAndExit(errors.New("DISABLE_LOCAL_AUTH is enabled and an OAUTH2_PROVIDER is configured, but OAUTH2_USER_CREATION is not enabled"))
|
|
||||||
case config.Opts.AuthProxyHeader() != "" && !config.Opts.IsAuthProxyUserCreationAllowed():
|
|
||||||
printErrorAndExit(errors.New("DISABLE_LOCAL_AUTH is enabled and an AUTH_PROXY_HEADER is configured, but AUTH_PROXY_USER_CREATION is not enabled"))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
startDaemon(store)
|
startDaemon(store)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue