Skip to content

Commit 8d5e6f3

Browse files
authored
fix: fix IsGithubDotComURL check (#17022)
When DeviceFlow with GitHub OAuth2 is configured, the `api.GithubOAuth2Config.AuthCode` is [overridden](https://github.com/coder/coder/blob/b08c8c9e1ee8edf18e9ba575098d99533062a240/coderd/userauth.go#L779) and returns a value that doesn't pass the `IsGithubDotComURL` check. This PR ensures the original `AuthCodeURL` method is used instead.
1 parent 7d60186 commit 8d5e6f3

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

coderd/userauth.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1096,7 +1096,10 @@ func (api *API) userOAuth2Github(rw http.ResponseWriter, r *http.Request) {
10961096
}
10971097
// If the user is logging in with github.com we update their associated
10981098
// GitHub user ID to the new one.
1099-
if externalauth.IsGithubDotComURL(api.GithubOAuth2Config.AuthCodeURL("")) && user.GithubComUserID.Int64 != ghUser.GetID() {
1099+
// We use AuthCodeURL from the OAuth2Config field instead of the one on
1100+
// GithubOAuth2Config because when device flow is configured, AuthCodeURL
1101+
// is overridden and returns a value that doesn't pass the URL check.
1102+
if externalauth.IsGithubDotComURL(api.GithubOAuth2Config.OAuth2Config.AuthCodeURL("")) && user.GithubComUserID.Int64 != ghUser.GetID() {
11001103
err = api.Database.UpdateUserGithubComUserID(ctx, database.UpdateUserGithubComUserIDParams{
11011104
ID: user.ID,
11021105
GithubComUserID: sql.NullInt64{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy