Skip to content

Commit fd87859

Browse files
committed
[feat] support custom GitHub OAuth2 auth and token URLs
1 parent c87f489 commit fd87859

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

pkg/api/authn.go

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -587,12 +587,24 @@ func NewRelyingPartyGithub(config *config.Config, provider string, hashKey, encr
587587
_, clientID, clientSecret, redirectURI, scopes,
588588
options := getRelyingPartyArgs(config, provider, hashKey, encryptKey, log)
589589

590+
var endpoint oauth2.Endpoint
591+
592+
// Use custom endpoints if provided, otherwise fallback to GitHub's endpoints
593+
if provider := config.HTTP.Auth.OpenID.Providers[provider]; provider.AuthUrl != "" && provider.TokenUrl != "" {
594+
endpoint = oauth2.Endpoint{
595+
AuthURL: provider.AuthUrl,
596+
TokenURL: provider.TokenUrl,
597+
}
598+
} else {
599+
endpoint = githubOAuth.Endpoint
600+
}
601+
590602
rpConfig := &oauth2.Config{
591603
ClientID: clientID,
592604
ClientSecret: clientSecret,
593605
RedirectURL: redirectURI,
594606
Scopes: scopes,
595-
Endpoint: githubOAuth.Endpoint,
607+
Endpoint: endpoint,
596608
}
597609

598610
relyingParty, err := rp.NewRelyingPartyOAuth(rpConfig, options...)

pkg/api/config/config.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ type OpenIDProviderConfig struct {
100100
ClientSecret string
101101
KeyPath string
102102
Issuer string
103+
AuthUrl string
104+
TokenUrl string
103105
Scopes []string
104106
}
105107

0 commit comments

Comments
 (0)