Skip to content

Commit 263b925

Browse files
committed
rename cookie from challenge to verifier
1 parent 37aa4c0 commit 263b925

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

coderd/httpmw/oauth2.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ func ExtractOAuth2(config promoauth.OAuth2Config, client *http.Client, cookieCfg
146146
authOpts = append(authOpts, oauth2.S256ChallengeOption(verifier))
147147

148148
http.SetCookie(rw, cookieCfg.Apply(&http.Cookie{
149-
Name: codersdk.OAuth2PKCEChallenge,
149+
Name: codersdk.OAuth2PKCEVerifier,
150150
Value: verifier,
151151
Path: "/",
152152
HttpOnly: true,
@@ -185,14 +185,14 @@ func ExtractOAuth2(config promoauth.OAuth2Config, client *http.Client, cookieCfg
185185

186186
exchangeOpts := make([]oauth2.AuthCodeOption, 0)
187187
if sha256PKCESupported {
188-
pkceChallenge, err := r.Cookie(codersdk.OAuth2PKCEChallenge)
188+
pkceVerifier, err := r.Cookie(codersdk.OAuth2PKCEVerifier)
189189
if err != nil {
190190
httpapi.Write(ctx, rw, http.StatusBadRequest, codersdk.Response{
191191
Message: "PKCE challenge must be provided.",
192192
})
193193
return
194194
}
195-
exchangeOpts = append(exchangeOpts, oauth2.VerifierOption(pkceChallenge.Value))
195+
exchangeOpts = append(exchangeOpts, oauth2.VerifierOption(pkceVerifier.Value))
196196
}
197197

198198
oauthToken, err := config.Exchange(ctx, code, exchangeOpts...)

coderd/userauth_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1018,7 +1018,7 @@ func TestUserOAuth2Github(t *testing.T) {
10181018
Value: "somestate",
10191019
})
10201020
req.AddCookie(&http.Cookie{
1021-
Name: codersdk.OAuth2PKCEChallenge,
1021+
Name: codersdk.OAuth2PKCEVerifier,
10221022
Value: oauth2.GenerateVerifier(),
10231023
})
10241024
require.NoError(t, err)
@@ -2465,7 +2465,7 @@ func oauth2Callback(t *testing.T, client *codersdk.Client, opts ...func(*http.Re
24652465
Value: state,
24662466
})
24672467
req.AddCookie(&http.Cookie{
2468-
Name: codersdk.OAuth2PKCEChallenge,
2468+
Name: codersdk.OAuth2PKCEVerifier,
24692469
Value: oauth2.GenerateVerifier(),
24702470
})
24712471
res, err := client.HTTPClient.Do(req)

codersdk/client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ const (
3838
SessionTokenHeader = "Coder-Session-Token"
3939
// OAuth2StateCookie is the name of the cookie that stores the oauth2 state.
4040
OAuth2StateCookie = "oauth_state"
41-
42-
OAuth2PKCEChallenge = "oauth_pkce_challenge"
41+
// OAuth2PKCEVerifier is the name of the cookie that stores the oauth2 PKCE
42+
// verifier. This is the raw verifier that when hashed, will match the challenge
43+
// sent in the initial oauth2 request.
44+
OAuth2PKCEVerifier = "oauth_pkce_verifier"
4345
// OAuth2RedirectCookie is the name of the cookie that stores the oauth2 redirect.
4446
OAuth2RedirectCookie = "oauth_redirect"
4547

0 commit comments

Comments
 (0)