mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-10-09 07:55:35 +02:00
deref everything but now with default constants
Signed-off-by: Jan Larwig <jan@larwig.com>
This commit is contained in:
@@ -35,7 +35,7 @@ func Validate(o *options.Options) error {
|
||||
transport := requests.DefaultTransport.(*http.Transport)
|
||||
transport.TLSClientConfig = &tls.Config{InsecureSkipVerify: true} // #nosec G402 -- InsecureSkipVerify is a configurable option we allow
|
||||
} else if len(o.Providers[0].CAFiles) > 0 {
|
||||
pool, err := util.GetCertPool(o.Providers[0].CAFiles, ptr.Deref(o.Providers[0].UseSystemTrustStore, false))
|
||||
pool, err := util.GetCertPool(o.Providers[0].CAFiles, ptr.Deref(o.Providers[0].UseSystemTrustStore, options.DefaultUseSystemTrustStore))
|
||||
if err == nil {
|
||||
transport := requests.DefaultTransport.(*http.Transport)
|
||||
transport.TLSClientConfig = &tls.Config{
|
||||
|
||||
@@ -65,7 +65,7 @@ func validateProvider(provider options.Provider, providerIDs map[string]struct{}
|
||||
// providerRequiresClientSecret checks if provider requires client secret to be set
|
||||
// or it can be omitted in favor of JWT token to authenticate oAuth client
|
||||
func providerRequiresClientSecret(provider options.Provider) bool {
|
||||
if provider.Type == "entra-id" && ptr.Deref(provider.MicrosoftEntraIDConfig.FederatedTokenAuth, false) {
|
||||
if provider.Type == "entra-id" && ptr.Deref(provider.MicrosoftEntraIDConfig.FederatedTokenAuth, options.DefaultMicrosoftEntraIDUseFederatedToken) {
|
||||
return false
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ func validateGoogleConfig(provider options.Provider) []string {
|
||||
|
||||
hasAdminEmail := provider.GoogleConfig.AdminEmail != ""
|
||||
hasSAJSON := provider.GoogleConfig.ServiceAccountJSON != ""
|
||||
useADC := ptr.Deref(provider.GoogleConfig.UseApplicationDefaultCredentials, false)
|
||||
useADC := ptr.Deref(provider.GoogleConfig.UseApplicationDefaultCredentials, options.DefaultUseApplicationDefaultCredentials)
|
||||
|
||||
if !hasAdminEmail && !hasSAJSON && !useADC {
|
||||
return msgs
|
||||
@@ -124,7 +124,7 @@ func validateGoogleConfig(provider options.Provider) []string {
|
||||
func validateEntraConfig(provider options.Provider) []string {
|
||||
msgs := []string{}
|
||||
|
||||
if ptr.Deref(provider.MicrosoftEntraIDConfig.FederatedTokenAuth, false) {
|
||||
if ptr.Deref(provider.MicrosoftEntraIDConfig.FederatedTokenAuth, options.DefaultMicrosoftEntraIDUseFederatedToken) {
|
||||
federatedTokenPath := os.Getenv("AZURE_FEDERATED_TOKEN_FILE")
|
||||
|
||||
if federatedTokenPath == "" {
|
||||
|
||||
@@ -55,28 +55,28 @@ func validateUpstream(upstream options.Upstream, ids, paths map[string]struct{})
|
||||
func validateStaticUpstream(upstream options.Upstream) []string {
|
||||
msgs := []string{}
|
||||
|
||||
if !ptr.Deref(upstream.Static, false) && upstream.StaticCode != nil {
|
||||
if !ptr.Deref(upstream.Static, options.DefaultUpstreamStatic) && upstream.StaticCode != nil {
|
||||
msgs = append(msgs, fmt.Sprintf("upstream %q has staticCode (%d), but is not a static upstream, set 'static' for a static response", upstream.ID, *upstream.StaticCode))
|
||||
}
|
||||
|
||||
// Checks after this only make sense when the upstream is static
|
||||
if !ptr.Deref(upstream.Static, false) {
|
||||
if !ptr.Deref(upstream.Static, options.DefaultUpstreamStatic) {
|
||||
return msgs
|
||||
}
|
||||
|
||||
if upstream.URI != "" {
|
||||
msgs = append(msgs, fmt.Sprintf("upstream %q has uri, but is a static upstream, this will have no effect.", upstream.ID))
|
||||
}
|
||||
if ptr.Deref(upstream.InsecureSkipTLSVerify, false) {
|
||||
if ptr.Deref(upstream.InsecureSkipTLSVerify, options.DefaultUpsteamInsecureSkipTLSVerify) {
|
||||
msgs = append(msgs, fmt.Sprintf("upstream %q has insecureSkipTLSVerify, but is a static upstream, this will have no effect.", upstream.ID))
|
||||
}
|
||||
if ptr.Deref(upstream.FlushInterval, options.DefaultUpstreamFlushInterval) != options.DefaultUpstreamFlushInterval {
|
||||
msgs = append(msgs, fmt.Sprintf("upstream %q has flushInterval, but is a static upstream, this will have no effect.", upstream.ID))
|
||||
}
|
||||
if ptr.Deref(upstream.PassHostHeader, false) {
|
||||
if ptr.Deref(upstream.PassHostHeader, options.DefaultUpstreamPassHostHeader) {
|
||||
msgs = append(msgs, fmt.Sprintf("upstream %q has passHostHeader, but is a static upstream, this will have no effect.", upstream.ID))
|
||||
}
|
||||
if ptr.Deref(upstream.ProxyWebSockets, false) {
|
||||
if ptr.Deref(upstream.ProxyWebSockets, options.DefaultUpstreamProxyWebSockets) {
|
||||
msgs = append(msgs, fmt.Sprintf("upstream %q has proxyWebSockets, but is a static upstream, this will have no effect.", upstream.ID))
|
||||
}
|
||||
|
||||
@@ -86,13 +86,13 @@ func validateStaticUpstream(upstream options.Upstream) []string {
|
||||
func validateUpstreamURI(upstream options.Upstream) []string {
|
||||
msgs := []string{}
|
||||
|
||||
if !ptr.Deref(upstream.Static, false) && upstream.URI == "" {
|
||||
if !ptr.Deref(upstream.Static, options.DefaultUpstreamStatic) && upstream.URI == "" {
|
||||
msgs = append(msgs, fmt.Sprintf("upstream %q has empty uri: uris are required for all non-static upstreams", upstream.ID))
|
||||
return msgs
|
||||
}
|
||||
|
||||
// Checks after this only make sense the upstream is not static
|
||||
if !ptr.Deref(upstream.Static, false) {
|
||||
if !ptr.Deref(upstream.Static, options.DefaultUpstreamStatic) {
|
||||
return msgs
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user