Skip to content

FGAP v2: Introduce fine-grained RESET_PASSWORD capability with deny-overrides evaluation#41884

Closed
Bagautdino wants to merge 4 commits intokeycloak:mainfrom
Bagautdino:main
Closed

FGAP v2: Introduce fine-grained RESET_PASSWORD capability with deny-overrides evaluation#41884
Bagautdino wants to merge 4 commits intokeycloak:mainfrom
Bagautdino:main

Conversation

@Bagautdino
Copy link
Contributor

This PR introduces a dedicated RESET_PASSWORD capability to the USERS resource
in FGAP v2 (Fine-Grained Admin Permissions), enabling precise control over
password reset operations.

Key changes:

  • Added RESET_PASSWORD scope to AdminPermissionsSchema for USERS.
  • Extended UserPermissionEvaluator and UserPermissions to expose canResetPassword()
    and requireResetPassword().
  • Implemented full FGAP v2 evaluation for RESET_PASSWORD in UserPermissionsV2:
    • Deny-overrides decision model.
    • Secure-by-default behavior when policies exist.
    • Optional fallback to legacy MANAGE_USERS via fgap.v2.resetPassword.fallbackToManageUsers (default=false).
  • Updated UserResource.resetPassword() to require RESET_PASSWORD instead of MANAGE_USERS.
  • getAccess(user) now includes resetPassword flag for UI control.
  • Preserved self-service password change (caller == target user) without FGAP checks.
  • Added utility to detect policies referencing RESET_PASSWORD scope.
  • Enhanced auditing/logging for allow/deny decisions.

Behavior changes:

  • When FGAP v2 is enabled and a RESET_PASSWORD policy exists, MANAGE_USERS alone
    no longer grants password reset rights.
  • Explicit DENY policies always override ALLOW.
  • Self-service flows remain unaffected.
  • When no RESET_PASSWORD policies are present:
    • fallback=false → deny by default.
    • fallback=true → allow if MANAGE_USERS is granted.

Includes:

  • Configuration key: fgap.v2.resetPassword.fallbackToManageUsers (bool, default=false).
  • Unit and integration tests covering all decision paths.
  • Admin Console support via access.resetPassword flag (hides Reset Password button when false).
  • Migration hook to optionally create a default DENY policy for RESET_PASSWORD upon FGAP v2 enablement.

This change strengthens password reset governance by ensuring
policy-based control and removing implicit MANAGE_USERS inheritance
when fine-grained permissions are in effect.

@Bagautdino Bagautdino requested a review from a team as a code owner August 14, 2025 14:23
Copy link
Member

@ahus1 ahus1 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for this change, this looks like a great addition.

To align with our CONTRIBUTING.md guide, please create an enhancement issue in addition to the PR to describe why this enhancement is needed, and then link the two. I can help with the linking if you drop the issue number in a comment.

In general, avoid creating comments by merging main, as they are difficult when rebasing the PR.

Also, only rebase when there are conflicts or a maintainer asks you to rebase.

Thanks!

@ahus1
Copy link
Member

ahus1 commented Aug 14, 2025

Also: Please sign-off your commits to make the DCO action pass.

@ahus1
Copy link
Member

ahus1 commented Aug 14, 2025

cc: @keycloak/core-iam, this might be an interesting PR coming up.

@Bagautdino Bagautdino closed this by deleting the head repository Aug 15, 2025
@ahus1
Copy link
Member

ahus1 commented Aug 15, 2025

Follow-up PR: #41904

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants