Skip to content

[18.0][IMP] impersonate_login: impersonation mode per user - #1052

Open
klodr wants to merge 3 commits into
OCA:18.0from
klodr:18.0-imp-impersonate_login-per-user
Open

klodr wants to merge 3 commits into
OCA:18.0from
klodr:18.0-imp-impersonate_login-per-user

Conversation

@klodr

@klodr klodr commented Oct 24, 2026

Copy link
Copy Markdown

Today the only way to protect a user from being impersonated is the general setting added in #954, which applies to all users with the Administration: Settings rights. There is no way to:

  • protect one specific user that has no admin rights (a technical or API account, a sensitive account), or
  • allow impersonating one specific administrator while keeping the general restriction for the others.

This PR adds an Impersonation setting on each user (Access Rights tab, visible and editable by administrators only):

Mode Behaviour
Default unchanged: follows the general setting
Allowed the user can always be impersonated, even with the Administration: Settings rights
Forbidden the user can never be impersonated

The checks are grouped in _check_can_be_impersonated(), so other modules can extend them. The check is skipped when the impersonating user goes back to their own account.

Tests: three new HTTP tests (forbidden user, allowed administrator despite the general restriction, default mode follows the general restriction); the existing tests are unchanged and pass. README regenerated.

klodr added 2 commits October 24, 2026 09:35
Each user gets an Impersonation setting (administrators only, Access Rights
tab of the user form):
- Default: follow the general setting (Restrict Impersonation of
  'Administration: Settings' Users);
- Allowed: the user can always be impersonated, even with the
  'Administration: Settings' rights;
- Forbidden: the user can never be impersonated.

The check is skipped when going back to the original user.

Signed-off-by: Claude Perrin <klodr@users.noreply.github.com>
…ction

Signed-off-by: Claude Perrin <klodr@users.noreply.github.com>
@OCA-git-bot

Copy link
Copy Markdown
Contributor

Hi @Kev-Roche,
some modules you are maintaining are being modified, check this out!

The "Switch Login" list only shows the users that can be switched to, and
the row button of the users list is hidden for the others: oneself, users
set to Forbidden, and administrators in Default mode when the general
setting restricts them. Same rule as the server-side check, which is
unchanged, as a computed field with a SQL search.

Signed-off-by: Claude Perrin <klodr@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mod:impersonate_login Module impersonate_login series:18.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants