Skip to content

[20.0][MIG] oauth_provider: Migration to 20.0 - #1049

Open
augusto-weiss wants to merge 34 commits into
OCA:20.0from
adhoc-dev:20.0-t-76767-awe
Open

augusto-weiss wants to merge 34 commits into
OCA:20.0from
adhoc-dev:20.0-t-76767-awe

Conversation

@augusto-weiss

@augusto-weiss augusto-weiss commented Oct 21, 2026 •

Copy link
Copy Markdown

Depends on #1022 (19.0 migration, not merged yet): this branch carries its history.

Migration changes:

  • _auth_method_oauth_provider takes the new routing argument of ir.http in 20.0.
  • Access rights converted to ir.access with Odoo's upgrade_code.
  • Password grant: validate_user authenticates like Odoo RPC (interactive: False):
    accepts an RPC API key instead of the password, requires it when the user has 2FA,
    and no longer logs a web session in. It was broken since 17.0 (Session.authenticate signature).
  • /oauth2/token no longer forces all client scopes on the token: it gets the requested
    scopes, and with the authorization code grant the scopes granted to the code.
  • Refresh token grant: it keeps working once the access token expired (the lookups ignore
    the computed active filter), and the new token gets the owner of the refreshed one
    (validate_refresh_token sets it). The controller no longer passes the user through
    oauthlib extra credentials, so odoo_user_id is not in the token response anymore.
  • /oauth2/tokeninfo: expires_in uses the whole lifetime (timedelta.seconds dropped the days).
  • /oauth2/revoke_token: csrf=False (external clients can not send a CSRF token), no more
    500 on auth="none" (odoo_user.active read with sudo), and it also finds the refresh
    token of an expired access token.
  • readonly=False on the routes that write (auth="none" routes are readonly by default).
  • README moved to readme/ fragments; /oauth2/otherinfo documented as deprecated.

Tests:

  • They were disabled (commented imports) and relied on removed APIs (WebRequest,
    wsgi_server): the controller base now uses HttpCase, with its own user (no demo data).
  • The shared tests live in mixins and did not run (allow_inherited_tests_method).
  • 181 tests green locally (183 on a database without demo data). New tests for
    /oauth2/resources/<model>, API key + 2FA, code scopes, refresh and revoke with an expired
    access token, expires_in over a day, revoke without CSRF, the state roundtrip with unsafe
    characters.

CI note: tests pass; checklog fails on a core warning while compiling web.assets_frontend
without html_editor (odoo/odoo#287582), see the comment below.

Open questions:

  • API keys created in 19.0 with an empty scope and the 20.0 non-interactive login, which looks
    for scope = 'rpc'.
  • The access rights keep their xmlids but move from ir.model.access to ir.access; Odoo's
    upgrade converts them, not checked with OpenUpgrade.

Sylvain GARANCHER and others added 30 commits October 21, 2026 14:58
OCA Transbot updated translations from Transifex

OCA Transbot updated translations from Transifex

OCA Transbot updated translations from Transifex

OCA Transbot updated translations from Transifex

OCA Transbot updated translations from Transifex

OCA Transbot updated translations from Transifex

[UPD] Update oauth_provider.pot
Lines removed tries to write on `client_id` attribute of the
`oauth.provider.client` which do not have such an attribute.
Theses sentences seams useless, so I removed it.
This module uses the method `get_frontend_session_info()` from
`ir.http`, and this method is defined in the web module.
The bug is introduced by commit d46db56.

The oauth.provider.client model is used to fill the `request.client`
field in the _load_client() method of the OdooValidator class.

The oauthlib python library need that the `client` object set in the `request`
by the OdooValidator must contain an attribute named `client_id` which must
contain the identifier of the oauth.provider.client. In other words the
`client_id` attribute of the `client` object must contain the
`client_id` that is posted by the HTTP request to the server.
Source here:
https://github.com/oauthlib/oauthlib/blob/dab6a5ae1830ddd8a79c1e9687f63508eae60b57/oauthlib/oauth2/rfc6749/grant_types/authorization_code.py#L471-L474

The client_id was previously not part of the `oauth.provider.client`
odoo model because it conflict in term of nomenclature with the odoo way
of defining fields name. So it was added on the fly after for the record
given to the oauthlib.

Now, its not allowed to add such field like this, and doing that without
explanation is quite confusing.

So now the field with a name that breaks the Odoo nomenclature is added
with a comment so that we can understand the exception done here.
@augusto-weiss

Copy link
Copy Markdown
Author

Tests are green (172, 0 failed / 0 errors). The red comes from checklog, on a core warning
while compiling web.assets_frontend:

Error: argument `$color` of `rgba($color, $alpha)` must be a color

Since 7c69596e7997, web/static/src/scss/bootstrap_review_frontend.scss uses
increase-contrast, which is only defined in html_editor. On a database without
html_editor (as in CI: only base, web and this module) the frontend bundle does not
compile. This module renders web.login_layout in its authorization tests, so it hits it.
Fix pending in odoo/odoo#287582. #1040 (auth_saml) fails the same way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants