You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat: No way to fetch external auth refresh token #12787
There is currently no way (or at least not via the Coder CLI or API) to fetch the refresh token for an external auth provider in Coder. I have an external app I am trying to integrate with coder, and its config files require both the access token and the refresh token as a starting point.
@kylecarbs brought up a good point. If the refresh token is exposed, it can be used to generate new tokens outside Coder, leaving coder with a stale refresh token.
What application specifically is requesting this? Maybe there is a workaround on that side?
After a bit of research I found we manage a wrapper around an API client library that is essentially the app we're trying to integrate, and that can be easily extended to use the coder CLI to get the updated access token instead of the client library which calls /v1/token itself to refresh tokens.
That library assumes the oauth2 apps are configured with a PKCE challenge rather than client secrets, so the requests from it to refresh the token itself fail.
At this point I'm fine to close this issue. I do agree that allowing refresh tokens to be used by other applications would mean a divergence between that app's access tokens and those known by coder, but in cases where they're absolutely needed to integrate an app I'd happily live with it I think. In our case, though, we're happy to live with the workaround we have now.
If we did expose a refresh_token it would also break any other workspaces that are sharing the same external auth app. Since 1 workspace "takes charge" of it.
I'm curious why the refresh token is required to auth into your app anyway 🤔. Feels strange, unless it is a clientside app that is managing some oauth state.
@ns-mkusper I see. I think this is a general problem we might run into more often. Where a client app wants to manage the token lifecycle.
I think allowing Coderd & a clientside app to manage a token is not a can of worms I'd like to open.
A better approach would be to generate a fresh token for each workspace. The external auth token could be used by the startup scripts to create a new one. Cleaning up tokens might not be trivial if they have a long TTL.
As a summary though, I am going to close this issue. I appreciate the communication of the challenges you are facing. If this arises for other apps and clients, I'll merge things into a larger ticket 👍
Activity
[-]No way to fetch external auth refresh token[/-][+]feat: No way to fetch external auth refresh token[/+]matifali commentedon Mar 28, 2024
cc: @Emyrk @kylecarbs
Also related to #12704 where the user is requesting
usernameto be added tocoder_external_auth.kylecarbs commentedon Mar 28, 2024
@matifali we will do this but should not do the other.
Emyrk commentedon Mar 28, 2024
I feel like the cli should be able to expose the user external-auth api endpoints.
The workspace agent endpoint is a bit limiting in the fact it's designed for
ASK_PASSstyle prompting.We could add
lsand other commands using the user apis.ns-mkusper commentedon Mar 28, 2024
If we could fetch the refresh token via the coder CLI that would be great.
Emyrk commentedon Mar 28, 2024
@kylecarbs brought up a good point. If the refresh token is exposed, it can be used to generate new tokens outside Coder, leaving coder with a stale refresh token.
What application specifically is requesting this? Maybe there is a workaround on that side?
ns-mkusper commentedon Mar 28, 2024
After a bit of research I found we manage a wrapper around an API client library that is essentially the app we're trying to integrate, and that can be easily extended to use the coder CLI to get the updated access token instead of the client library which calls
/v1/tokenitself to refresh tokens.That library assumes the oauth2 apps are configured with a PKCE challenge rather than client secrets, so the requests from it to refresh the token itself fail.
At this point I'm fine to close this issue. I do agree that allowing refresh tokens to be used by other applications would mean a divergence between that app's access tokens and those known by coder, but in cases where they're absolutely needed to integrate an app I'd happily live with it I think. In our case, though, we're happy to live with the workaround we have now.
Emyrk commentedon Mar 29, 2024
If we did expose a
refresh_tokenit would also break any other workspaces that are sharing the same external auth app. Since 1 workspace "takes charge" of it.I'm curious why the refresh token is required to auth into your app anyway 🤔. Feels strange, unless it is a clientside app that is managing some oauth state.
ns-mkusper commentedon Mar 29, 2024
It is indeed a client-side app that is managing Oauth state on its own.
Emyrk commentedon Mar 29, 2024
Are you able to share what that app is? @ns-mkusper
ns-mkusper commentedon Mar 29, 2024
Yep, this is the app in question: https://github.com/rigetti/qcs-api-client-python
Emyrk commentedon Apr 1, 2024
@ns-mkusper I see. I think this is a general problem we might run into more often. Where a client app wants to manage the token lifecycle.
I think allowing Coderd & a clientside app to manage a token is not a can of worms I'd like to open.
A better approach would be to generate a fresh token for each workspace. The external auth token could be used by the startup scripts to create a new one. Cleaning up tokens might not be trivial if they have a long TTL.
As a summary though, I am going to close this issue. I appreciate the communication of the challenges you are facing. If this arises for other apps and clients, I'll merge things into a larger ticket 👍