Skip to content

Commit bf1c3a6

Browse files
committed
fix: prevent refreshing tokens that don't exist
- When logging in with Google OIDC refresh tokens are not provided unless explicitly asked for. This PR updates the logic to avoid attempting to refresh the token if a refresh token does not exist. A session should only be dependent on a valid Coder API key, the state of its OAuth token (beyond initial authentication) should be irrelevant.
1 parent ea156cc commit bf1c3a6

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

coderd/httpmw/apikey.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ func ExtractAPIKey(cfg ExtractAPIKeyConfig) func(http.Handler) http.Handler {
203203
return
204204
}
205205
// Check if the OAuth token is expired
206-
if link.OAuthExpiry.Before(now) && !link.OAuthExpiry.IsZero() {
206+
if link.OAuthExpiry.Before(now) && !link.OAuthExpiry.IsZero() && link.OAuthRefreshToken != "" {
207207
var oauthConfig OAuth2Config
208208
switch key.LoginType {
209209
case database.LoginTypeGithub:

0 commit comments

Comments
 (0)