Repository navigation
Conversation
Odoo can log users in through external providers (auth_oauth, auth_oidc, auth_saml) and accept bearer JWTs on routes (auth_jwt), but nothing lets it issue tokens to third-party applications. This module makes Odoo an OAuth 2.1 authorization server, following what the MCP authorization specification requires, so that MCP clients can connect to an MCP server hosted in Odoo by having the user log in and approve. - Authorization code flow with mandatory PKCE (S256). Refresh tokens are stored as digests and rotated on each use; reusing a code or a rotated refresh token revokes the authorization. - Discovery: authorization server metadata (RFC 8414) and protected resource metadata (RFC 9728). - Clients registered by an administrator, through dynamic registration (RFC 7591), or identified by a Client ID Metadata Document, fetched from public addresses only. - Tokens bound to the resource they were asked for (RFC 8707), iss in authorization responses (RFC 9207), token revocation (RFC 7009). - Access tokens are short-lived JWTs signed with an auth_jwt validator created for each protected resource, so routes can use auth="jwt_<validator>". Each token is also checked against its authorization, so revoking one takes effect at once. - Login is left to Odoo's login page (password, two-factor, auth_oauth, ...), followed by a consent page bound to the validated request. - Users see and revoke the applications they connected in their preferences; administrators manage resources, clients and authorizations. Assisted-by: Claude Opus 5.5
- post_init_hook takes the environment; - settings in a block of their own, with the 17.0 setting layout; - attrs turned into Python expressions, tree into list; the fields only used in expressions are no longer declared invisible; the actions have a path; - the token, revocation and registration endpoints declare a read/write cursor: auth="none" routes are read-only by default since 17.2; - the tests remove the auth="jwt_..." methods auth_jwt adds to ir.http for the validators of the resources, which Odoo now reports as leaked; - f-strings and no bare expression, as ruff now requires.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Forward port of #1032