Skip to content

Commit 706aec2

Browse files
acohen4jrockway
authored andcommitted
Adding an oidcConnector config to decide whether to validate that the Connector Callback must contain the same host as the issuer
Author: acohen4 <alonco124@gmail.com>
1 parent 2bb4896 commit 706aec2

1 file changed

Lines changed: 38 additions & 33 deletions

File tree

connector/oidc/oidc.go

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ type Config struct {
5252
// Disable certificate verification
5353
InsecureSkipVerify bool `json:"insecureSkipVerify"`
5454

55+
// Skips checking whether the requested domain in the Login Callback matches the configured Issuer
56+
InsecureSkipIssuerCallbackDomainCheck bool `json:"insecureSkipIssuerCallbackDomainCheck"`
57+
5558
// GetUserInfo uses the userinfo endpoint to get additional claims for
5659
// the token. This is especially useful where upstreams return "thin"
5760
// id tokens
@@ -163,20 +166,21 @@ func (c *Config) Open(id string, logger log.Logger) (conn connector.Connector, e
163166
verifier: provider.Verifier(
164167
&oidc.Config{ClientID: clientID},
165168
),
166-
logger: logger,
167-
cancel: cancel,
168-
httpClient: httpClient,
169-
insecureSkipEmailVerified: c.InsecureSkipEmailVerified,
170-
insecureEnableGroups: c.InsecureEnableGroups,
171-
acrValues: c.AcrValues,
172-
getUserInfo: c.GetUserInfo,
173-
promptType: c.PromptType,
174-
userIDKey: c.UserIDKey,
175-
userNameKey: c.UserNameKey,
176-
overrideClaimMapping: c.OverrideClaimMapping,
177-
preferredUsernameKey: c.ClaimMapping.PreferredUsernameKey,
178-
emailKey: c.ClaimMapping.EmailKey,
179-
groupsKey: c.ClaimMapping.GroupsKey,
169+
logger: logger,
170+
cancel: cancel,
171+
httpClient: httpClient,
172+
insecureSkipEmailVerified: c.InsecureSkipEmailVerified,
173+
insecureEnableGroups: c.InsecureEnableGroups,
174+
acrValues: c.AcrValues,
175+
getUserInfo: c.GetUserInfo,
176+
promptType: c.PromptType,
177+
userIDKey: c.UserIDKey,
178+
userNameKey: c.UserNameKey,
179+
overrideClaimMapping: c.OverrideClaimMapping,
180+
preferredUsernameKey: c.ClaimMapping.PreferredUsernameKey,
181+
emailKey: c.ClaimMapping.EmailKey,
182+
groupsKey: c.ClaimMapping.GroupsKey,
183+
insecureSkipIssuerCallbackDomainCheck: c.InsecureSkipIssuerCallbackDomainCheck,
180184
}, nil
181185
}
182186

@@ -186,24 +190,25 @@ var (
186190
)
187191

188192
type oidcConnector struct {
189-
provider *oidc.Provider
190-
redirectURI string
191-
oauth2Config *oauth2.Config
192-
verifier *oidc.IDTokenVerifier
193-
cancel context.CancelFunc
194-
logger log.Logger
195-
httpClient *http.Client
196-
insecureSkipEmailVerified bool
197-
insecureEnableGroups bool
198-
acrValues []string
199-
getUserInfo bool
200-
promptType string
201-
userIDKey string
202-
userNameKey string
203-
overrideClaimMapping bool
204-
preferredUsernameKey string
205-
emailKey string
206-
groupsKey string
193+
provider *oidc.Provider
194+
redirectURI string
195+
oauth2Config *oauth2.Config
196+
verifier *oidc.IDTokenVerifier
197+
cancel context.CancelFunc
198+
logger log.Logger
199+
httpClient *http.Client
200+
insecureSkipEmailVerified bool
201+
insecureEnableGroups bool
202+
acrValues []string
203+
getUserInfo bool
204+
promptType string
205+
userIDKey string
206+
userNameKey string
207+
overrideClaimMapping bool
208+
preferredUsernameKey string
209+
emailKey string
210+
groupsKey string
211+
insecureSkipIssuerCallbackDomainCheck bool
207212
}
208213

209214
func (c *oidcConnector) Close() error {
@@ -212,7 +217,7 @@ func (c *oidcConnector) Close() error {
212217
}
213218

214219
func (c *oidcConnector) LoginURL(s connector.Scopes, callbackURL, state string) (string, error) {
215-
if c.redirectURI != callbackURL {
220+
if c.redirectURI != callbackURL && !c.insecureSkipIssuerCallbackDomainCheck {
216221
return "", fmt.Errorf("expected callback URL %q did not match the URL in the config %q", callbackURL, c.redirectURI)
217222
}
218223

0 commit comments

Comments
 (0)