@@ -4,10 +4,46 @@ import "github.com/oauth2-proxy/oauth2-proxy/v7/pkg/util/ptr"
44
55const (
66 // OIDCEmailClaim is the generic email claim used by the OIDC provider.
7− OIDCEmailClaim = "email"
7+ OIDCEmailClaim string = "email"
88
99 // OIDCGroupsClaim is the generic groups claim used by the OIDC provider.
10− OIDCGroupsClaim = "groups"
10+ OIDCGroupsClaim string = "groups"
11+
12+ // DefaultSkipDiscovery is the default value
13+ // for OIDCOptions.SkipDiscovery
14+ DefaultSkipDiscovery bool = false
15+
16+ // DefaultInsecureSkipNonce is the default value
17+ // for OIDCOptions.InsecureSkipNonce
18+ DefaultInsecureSkipNonce bool = true
19+
20+ // DefaultInsecureAllowUnverifiedEmail is the default value
21+ // for OIDCOptions.InsecureAllowUnverifiedEmail
22+ DefaultInsecureAllowUnverifiedEmail bool = false
23+
24+ // DefaultInsecureSkipIssuerVerification is the default value
25+ // for OIDCOptions.InsecureSkipIssuerVerification
26+ DefaultInsecureSkipIssuerVerification bool = false
27+
28+ // DefaultSkipClaimsFromProfileURL is the default value
29+ // for Provider.SkipClaimsFromProfileURL
30+ DefaultSkipClaimsFromProfileURL bool = false
31+
32+ // DefaultADFSSkipScope is the default value
33+ // for ADFSOptions.SkipScope
34+ DefaultADFSSkipScope bool = false
35+
36+ // DefaultMicrosoftEntraIDUseFederatedToken is the default value
37+ // for MicrosoftEntraIDOptions.FederatedTokenAuth
38+ DefaultMicrosoftEntraIDUseFederatedToken bool = false
39+
40+ // DefaultGoogleUseApplicationDefaultCredentials is the default values
41+ // for GoogleOptions.UseApplicationDefaultCredentials
42+ DefaultUseApplicationDefaultCredentials bool = false
43+
44+ // DefaultUseSystemTrustStore is the default value
45+ // for Provider.UseSystemTrustStore
46+ DefaultUseSystemTrustStore bool = true
1147)
1248
1349// OIDCAudienceClaims is the generic audience claim list used by the OIDC provider.
@@ -298,9 +334,9 @@ func providerDefaults() Providers {
298334 Tenant: "common",
299335 },
300336 OIDCConfig: OIDCOptions{
301− InsecureAllowUnverifiedEmail: ptr.Ptr(false),
302− InsecureSkipNonce: ptr.Ptr(true),
303− SkipDiscovery: ptr.Ptr(false),
337+ InsecureAllowUnverifiedEmail: ptr.Ptr(DefaultInsecureAllowUnverifiedEmail),
338+ InsecureSkipNonce: ptr.Ptr(DefaultInsecureSkipNonce),
339+ SkipDiscovery: ptr.Ptr(DefaultSkipDiscovery),
304340 UserIDClaim: OIDCEmailClaim, // Deprecated: Use OIDCEmailClaim
305341 EmailClaim: OIDCEmailClaim,
306342 GroupsClaim: OIDCGroupsClaim,
@@ -322,10 +358,10 @@ func (p Providers) EnsureDefaults() {
322358// EnsureDefaults sets any default values for Provider fields.
323359func (p *Provider) EnsureDefaults() {
324360 if p.SkipClaimsFromProfileURL == nil {
325− p.SkipClaimsFromProfileURL = ptr.Ptr(false)
361+ p.SkipClaimsFromProfileURL = ptr.Ptr(DefaultSkipClaimsFromProfileURL)
326362 }
327363 if p.UseSystemTrustStore == nil {
328− p.UseSystemTrustStore = ptr.Ptr(true)
364+ p.UseSystemTrustStore = ptr.Ptr(DefaultUseSystemTrustStore)
329365 }
330366
331367 p.OIDCConfig.EnsureDefaults()
@@ -338,13 +374,13 @@ func (p *Provider) EnsureDefaults() {
338374func (o *OIDCOptions) EnsureDefaults() {
339375 // Ensure OIDC defaults
340376 if o.InsecureAllowUnverifiedEmail == nil {
341− o.InsecureAllowUnverifiedEmail = ptr.Ptr(false)
377+ o.InsecureAllowUnverifiedEmail = ptr.Ptr(DefaultInsecureAllowUnverifiedEmail)
342378 }
343379 if o.InsecureSkipNonce == nil {
344− o.InsecureSkipNonce = ptr.Ptr(true)
380+ o.InsecureSkipNonce = ptr.Ptr(DefaultInsecureSkipNonce)
345381 }
346382 if o.SkipDiscovery == nil {
347− o.SkipDiscovery = ptr.Ptr(false)
383+ o.SkipDiscovery = ptr.Ptr(DefaultSkipDiscovery)
348384 }
349385 if o.UserIDClaim == "" {
350386 o.UserIDClaim = OIDCEmailClaim
@@ -363,20 +399,20 @@ func (o *OIDCOptions) EnsureDefaults() {
363399// EnsureDefaults sets any default values for MicrosoftEntraIDOptions fields.
364400func (me *MicrosoftEntraIDOptions) EnsureDefaults() {
365401 if me.FederatedTokenAuth == nil {
366− me.FederatedTokenAuth = ptr.Ptr(false)
402+ me.FederatedTokenAuth = ptr.Ptr(DefaultMicrosoftEntraIDUseFederatedToken)
367403 }
368404}
369405
370406// EnsureDefaults sets any default values for ADFSOptions fields.
371407func (a *ADFSOptions) EnsureDefaults() {
372408 if a.SkipScope == nil {
373− a.SkipScope = ptr.Ptr(false)
409+ a.SkipScope = ptr.Ptr(DefaultADFSSkipScope)
374410 }
375411}
376412
377413// EnsureDefaults sets any default values for GoogleOptions fields.
378414func (g *GoogleOptions) EnsureDefaults() {
379415 if g.UseApplicationDefaultCredentials == nil {
380− g.UseApplicationDefaultCredentials = ptr.Ptr(false)
416+ g.UseApplicationDefaultCredentials = ptr.Ptr(DefaultUseApplicationDefaultCredentials)
381417 }
382418}