Skip to content

[20.0][MIG] auth_api_key: Migration to 20.0 - #1071

Open
cjallais wants to merge 107 commits into
OCA:20.0from
archeti-org:20.0-mig-auth_api_key
Open

cjallais wants to merge 107 commits into
OCA:20.0from
archeti-org:20.0-mig-auth_api_key

Conversation

@cjallais

Copy link
Copy Markdown

Migration changes

  • Bump version to 20.0.1.0.0.
  • Convert ir.model.access.csv to the new security/ir.access.csv (same rights: base.group_system, crud).
  • _auth_method_api_key now takes the routing argument passed by ir.http._authenticate_explicit.
  • Import Dispatcher from odoo.http.dispatcher (no longer re-exported by odoo.http).
  • Replace removed registry.clear_cache() with env.transaction.invalidate_ormcache() (model and tests).
  • Use api.ormcache instead of deprecated tools.ormcache.
  • Remove readme/CREDITS.md (past migration funding note), per 20.0 guidelines.
  • Lint fixes required by the 20.0 pre-commit config (single-line manifest summary, ruff C419).

Fix included

The API key lookup cache was only cleared when key or user_id changed, so a deleted or archived key could keep authenticating until the cache was cleared by something else. The model now uses _clear_cache_name
/ _clear_cache_on_fields = ("key", "user_id", "active"), so the ORM clears the cache on create, unlink and on writes of those fields. Two tests added (archive, unlink).

Known issues (pre-existing, not addressed here)

  1. Toggling "Disable API key for archived user" on a company does not clear the cache. Turning the option on recomputes active = False on keys of already-archived users, but the recompute does not go through
    write(), so a cached key keeps working until the cache is cleared. Note that the field help says the option is not retroactive, while the stored compute (depends on the company option) does make it retroactive —
    maintainers' input welcome on the intended behavior.
  2. _compute_active reads self.user_id.company_id.archived_user_disable_auth_api_key on the whole recordset, which may raise "Expected singleton" when keys of users from different companies are recomputed together
    (not reproduced).

Tests

15 tests, 0 failures (local run).

lmignon and others added 30 commits November 19, 2026 09:26
Get rid of keychain dependency
Co-Authored-By: qgroulard <43472442+qgroulard@users.noreply.github.com>
Api key is now based on the new version of server env
Key belong to a specifiv database that can be requested based on the
domain name.

Just setup the db_filter with "%d^" to filter based on domain name
Add a migration script to create the auth.api.key records from keys defined into the cfg file
Provides a specific serction name builder to continue reading the key info from the same section as the one expected by the previous version
OCA-git-bot and others added 27 commits November 19, 2026 09:26
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-auth-19.0/server-auth-19.0-auth_api_key
Translate-URL: https://translation.odoo-community.org/projects/server-auth-19-0/server-auth-19-0-auth_api_key/
Currently translated at 100.0% (25 of 25 strings)

Translation: server-auth-19.0/server-auth-19.0-auth_api_key
Translate-URL: https://translation.odoo-community.org/projects/server-auth-19-0/server-auth-19-0-auth_api_key/it/
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: server-auth-19.0/server-auth-19.0-auth_api_key
Translate-URL: https://translation.odoo-community.org/projects/server-auth-19-0/server-auth-19-0-auth_api_key/
Currently translated at 100.0% (26 of 26 strings)

Translation: server-auth-19.0/server-auth-19.0-auth_api_key
Translate-URL: https://translation.odoo-community.org/projects/server-auth-19-0/server-auth-19-0-auth_api_key/it/
The test creates its user with a 4 character password. That is fine for this
module alone, but the OCA CI installs every module of the repository into a
single database, and password_security depends on auth_password_policy_signup,
hence on auth_password_policy, whose data file installs a minimum length of 8:
 - https://github.com/odoo/odoo/blob/13e9e827dc21103052e8607d16f23c07adeb5634/addons/auth_password_policy/data/defaults.xml#L5

so setUpClass fails with:

    UserError: Your password must contain at least 8 characters and only has 4.

Checked with an A/B run: the module is green on its own and red as soon as
password_security shares the database.
The pylint-odoo version of template v1.48 makes attribute-string-redundant (W8113) mandatory. The removed labels are the ones Odoo already generates from the field name, so the UI does not change.
@oca-cla-bot

oca-cla-bot Bot commented Nov 19, 2026

Copy link
Copy Markdown

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.