@@ -13,11 +13,6 @@ import (
1313 "github.com/coder/coder/cryptorand"
1414)
1515
16- const (
17- oauth2StateCookieName = "oauth_state"
18- oauth2RedirectCookieName = "oauth_redirect"
19- )
20-
2116type oauth2StateKey struct {}
2217
2318type OAuth2State struct {
@@ -71,7 +66,7 @@ func ExtractOAuth2(config OAuth2Config) func(http.Handler) http.Handler {
7166 }
7267
7368 http .SetCookie (rw , & http.Cookie {
74- Name : oauth2StateCookieName ,
69+ Name : codersdk . OAuth2StateKey ,
7570 Value : state ,
7671 Path : "/" ,
7772 HttpOnly : true ,
@@ -80,7 +75,7 @@ func ExtractOAuth2(config OAuth2Config) func(http.Handler) http.Handler {
8075 // Redirect must always be specified, otherwise
8176 // an old redirect could apply!
8277 http .SetCookie (rw , & http.Cookie {
83- Name : oauth2RedirectCookieName ,
78+ Name : codersdk . OAuth2RedirectKey ,
8479 Value : r .URL .Query ().Get ("redirect" ),
8580 Path : "/" ,
8681 HttpOnly : true ,
@@ -98,10 +93,10 @@ func ExtractOAuth2(config OAuth2Config) func(http.Handler) http.Handler {
9893 return
9994 }
10095
101- stateCookie , err := r .Cookie (oauth2StateCookieName )
96+ stateCookie , err := r .Cookie (codersdk . OAuth2StateKey )
10297 if err != nil {
10398 httpapi .Write (rw , http .StatusUnauthorized , codersdk.Response {
104- Message : fmt .Sprintf ("Cookie %q must be provided." , oauth2StateCookieName ),
99+ Message : fmt .Sprintf ("Cookie %q must be provided." , codersdk . OAuth2StateKey ),
105100 })
106101 return
107102 }
@@ -113,7 +108,7 @@ func ExtractOAuth2(config OAuth2Config) func(http.Handler) http.Handler {
113108 }
114109
115110 var redirect string
116- stateRedirect , err := r .Cookie (oauth2RedirectCookieName )
111+ stateRedirect , err := r .Cookie (codersdk . OAuth2RedirectKey )
117112 if err == nil {
118113 redirect = stateRedirect .Value
119114 }
0 commit comments