Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

impl: support for OAuth2 [WIP]#209

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
fioan89 wants to merge13 commits intomain
base:main
Choose a base branch
Loading
fromimpl-support-for-oauth
Draft

Conversation

@fioan89
Copy link
Collaborator

@fioan89fioan89 commentedOct 13, 2025
edited
Loading

Recent versions of Coder act as an OAuth 2.1 authorization server for first- and third‑party applications.
This PR aims at providing support for authenticating via OAuth with Coder Toolbox and still retain backward compatibility for authentication via API tokens or via certificates.

This PR is a WIP:

  • Infrastructure code to discover if a Coder deployment supports OAuth2
  • Infrastructure code to discover the Coder OAuth2 endpoints
  • Infrastructure code to dynamically register Coder Toolbox as a client app
  • Toolbox API is configured so that authorization page can be launched
  • Token refresh is configured as well
  • The infrastructure for exchanging the authorization codes for tokens and handle of auth redirect URI
  • Add support for PKCE verification
  • Limit the permission scope to read workspaces, read templates, template versions, buildinfo, read/write workspace, agents + apps, read your own user details, authentication, read access to SSH keys
  • Retrieve the logged account
  • Update/Redesign the Login wizard screen to skip over the token step if OAuth is available
  • Offer an optional link with text to the effect of, “Can’t authenticate? Generate a token” that will reload the page with a generated token if clicked.
  • Integrate with Coder CLI, authenticate the CLI with OAuth2 as well.
  • Update documentation

Toolbox API comes with a basic oauth2 client. This commitsets-up details about two important oauth flows:- authorization flow, in which the user is sent to web page  where an authorization code is generated which is exchanged  for an access token.- details about token refresh endpoint where users can obtain  a new access token and a new refresh token.A couple of important aspects:- the client app id is resolved in upstream- as well as the actual endpoints for authorization and token refresh- S256 is the only code challenge supported
…ation urlOAuth endpoint `.well-known/oauth-authorization-server` provides metadata aboutthe endpoint for dynamic client registration and supported response types.This commit adds support for deserializing these values.
OAuth allows programatic client registration for apps like Coder Toolboxvia the DCR endpoint which requires a name for the client app, the requestedscopes, redirect URI, etc... DCR replies back with a similar structure butin addition it returs two very important properties: client_id - a uniqueclient identifier string and also a client_secret - a secret string valueused by clients to authenticate to the token endpoint.
Code Toolbox plugin should protect against authorization code interceptionattacks by making use of the PKCE security extension which involvesa cryptographically random string (128 characters) known as code verifierand a code challenge - derived from code verifier using the S256 challenge method.
The OAuth2-compatible authentication manager provided by Toolbox
- authentication and token endpoints are now passed via the login configuration object- similar for client_id and client_secret- PCKE is now enabled
…injection- remove ServiceLocator dependency from CoderToolboxContext- move OAuth manager creation to CoderToolboxExtension for cleaner separation- Refactor CoderOAuthManager to use configuration-based approach instead of constructor injectionThe idea behind these changes is that createRefreshConfig API does not receive a configurationobject that can provide the client id and secret and even the refresh url. So initiallywe worked around the issue by passing the necessary data via the constructor. However this approachmeans a couple of things:- the actual auth manager can be created only at a very late stage, when a URL is provided by users- can't easily pass arround the auth manager without coupling the components- have to recreate a new auth manager instance if the user logs out and logs in to a different URL- service locator needs to be passed around because this is the actual factory of oauth managers in ToolboxInstead, we went with a differet approach, COderOAuthManager will derive and store the refresh configs oncethe authorization config is received. If the user logs out and logs in to a different URL the refresh data isalso guaranteed to be updated. And on top of that - this approach allows us to get rid of all of the issuesmentioned above.
Toolbox can handle automatically the exchange of an authorization code with a tokenby handling the custom URI for oauth. This commit calls the necessary APIin the Coder Toolbox URI handling.
@fioan89fioan89 changed the titleimpl: support for OAuth2impl: support for OAuth2 [WIP]Oct 14, 2025
POST /api/v2/oauth2-provider/apps is actually for manual adminregistration for admin created apps. Programmatic Dynamic ClientRegistration is done via `POST /oauth2/register`.At the same time I included `registration_access_token` and `registration_client_uri`to use it later in order to refresh the client secret without re-registering the client app.
A bunch of code thrown around to launch the OAuth flow.Still needs a couple of things:- persist the client id and registration uri and token- re-use client id instead of re-register every time- properly handle scenarios where OAuth is not available- the OAuth right now can be enabled if we log out and thenhit next in the deployment screen
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@f0sself0sselAwaiting requested review from f0ssel

@jcjiangjcjiangAwaiting requested review from jcjiang

At least 1 approving review is required to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

1 participant

@fioan89

[8]ページ先頭

©2009-2025 Movatter.jp