Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bug: api key not refreshed when api key expired but oauth2 access token not #17070

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
1 task done
hugodutka opened this issue Mar 24, 2025 · 3 comments
Open
1 task done
Assignees
Labels
s2 Broken use cases or features (with a workaround). Only humans may set this.

Comments

@hugodutka
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Current Behavior

We have a system that refreshes expired api keys backed by oauth2 if a refresh token is available.

However, in the case when the api key is expired but the oauth2 access token isn’t, the refresh logic is not triggered, and the api key ExpiresAt field is not updated.

Relavant check:

if link.OAuthExpiry.Before(now) && !link.OAuthExpiry.IsZero() && link.OAuthRefreshToken != "" {

Early exit if ExpiresAt is not updated.

if key.ExpiresAt.Before(now) {
return optionalWrite(http.StatusUnauthorized, codersdk.Response{
Message: SignedOutErrorMessage,
Detail: fmt.Sprintf("API key expired at %q.", key.ExpiresAt.String()),
})
}

Relevant Log Output

Expected Behavior

I'd expect the ExpiresAt field to be updated when a valid OAuth2 access token is available.

Steps to Reproduce

The way I triggered it is I manually updated the ExpiresAt field on an api key to the current time via a SQL query and then refreshed the Coder web UI.

Environment

  • Host OS: Linux
  • Coder version: 2.20.2

Additional Context

No response

@hugodutka hugodutka added the needs-triage Issue that require triage label Mar 24, 2025
@bpmct
Copy link
Member

bpmct commented Mar 24, 2025

@coder

Copy link

Starting a Coder workspace. You can track the progress here.

Copy link

✅ Workspace has been successfully started! You can access it here.

@matifali matifali added s2 Broken use cases or features (with a workaround). Only humans may set this. and removed needs-triage Issue that require triage labels May 7, 2025
@f0ssel f0ssel assigned f0ssel and spikecurtis and unassigned f0ssel May 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s2 Broken use cases or features (with a workaround). Only humans may set this.
Projects
None yet
Development

No branches or pull requests

5 participants