Skip to content

User roles don't work as expected in account console #23585

Closed

Description

@agagancarczyk

Before reporting an issue

Area

admin/api

Describe the bug

There are a couple of issues here worth considering:

  1. It appears that the 'manage-account' role (assigned to a new user automatically) makes the addition of account roles such as 'view-profile', 'manage-profile', 'view-applications', 'view-consent', and 'manage-consent' redundant, yet the user can be assigned these roles via User > selected new User > Role mapping > Assign role > Filter by clients.

  2. Removing the 'manage-account' role from realm settings > User registration results in 401 Unauthorized in the account console and the addition of any (account) role to a user doesn't have any effect, still resulting in 401 Unauthorized in the account console.

  3. Inherited roles (roles already added to a user on the user creation) such as manage-account, manage-account-links, and view-profile can be added again via select user > Assign role > Filter by clients

  4. Inconsistencies in role names and functions i.e. we have view-consent and manage-consent (which seem to be doing the same thing or maybe it's because of manage-account) but we only have view-profile which is a "read and write" type of role (maybe it's again because of manage-account role).

  5. Documentation explaining each account role is missing (what each role does, and how they can be enabled). Sometimes a few steps are required to enable a role but that's not documented. For example, adding a delete-account role to a user also requires going to Authentication/Required actions and setting 'Delete account' to On.

Version

22.0.3

Expected behavior

The above issues are addressed. At the moment it's very confusing how the roles are working.

Actual behavior

As outlined above.

How to Reproduce?

Steps and all details are provided in the issue.

Anything else?

No response

Activity

  1. added
    kind/bug
    on Sep 28, 2023
  2. ghost added
    area/admin/api
    on Sep 28, 2023
  3. added
    area/account/ui
    on Sep 28, 2023
  4. added
    area/account/api
    and removed
    area/admin/api
    on Sep 28, 2023
  5. pedroigor commented on Sep 28, 2023

    @pedroigor
    Contributor
    1. It appears that the 'manage-account' role (assigned to a new user automatically) makes the addition of account roles such as 'view-profile', 'manage-profile', 'view-applications', 'view-consent', and 'manage-consent' redundant, yet the user can be assigned these roles via User > selected new User > Role mapping > Assign role > Filter by clients.
    2. Removing the 'manage-account' role from realm settings > User registration results in 401 Unauthorized in the account console and the addition of any (account) role to a user doesn't have any effect, still resulting in 401 Unauthorized in the account console.

    The question here is whether we should enable certain areas of the UI and API. These areas are:

    • Profile (Personal Info)
    • Credentials (Account Security > Signing in)
    • Device (Account Security > Device activity)
    • Account Link (Account Security > Linked accounts)
    • Applications (Applications)
      ** Consent
    • Resources (Resources)
    • Groups

    From what I understand from the account console and looking at the account client roles, we should hide/show these areas depending on the account client roles assigned to the user. Access to those areas also involves checking whether the user has permission to read and write (perform actions) in these areas.

    However, I'm not sure if we are supposed to support such fine-grained control in all these areas. The roles we have today point toward this direction though.

    As you pointed out, if you take the Groups area as an example, it is shown depending on the view-groups role. Even if you have the manage-account role, groups are hidden if the user does not have the view-groups roles assigned. Why does it behave differently than others view-* roles?

    I did not check the old (the first one) account but I'll see how these roles play there.

    @stianst @mposolda @ssilvert What are your thoughts on this?

  6. pedroigor commented on Sep 28, 2023

    @pedroigor
    Contributor
    1. Inherited roles (roles already added to a user on the user creation) such as manage-account, manage-account-links, and view-profile can be added again via select user > Assign role > Filter by clients

    I agree it is confusing. The behavior is because those roles are inherited from the default role set. When you grant them directly to the user then you have a redundant role assignment.

    IMO, we should not make it possible at all to grant roles inherited from the default role set, or from any other composite role, or even if a role is granted by a group the user is a member of. Perhaps return an error from the API without necessarily hiding these roles from the UI (not ideal from a UX perspective).

  7. pedroigor commented on Sep 28, 2023

    @pedroigor
    Contributor
    1. Inconsistencies in role names and functions i.e. we have view-consent and manage-consent (which seem to be doing the same thing or maybe it's because of manage-account) but we only have view-profile which is a "read and write" type of role (maybe it's again because of manage-account role).

    It is somewhat related to #1 and #3. So we need to decide how much fine-grained access we want to enable around those areas in the account.

  8. pedroigor commented on Sep 28, 2023

    @pedroigor
    Contributor
    1. Documentation explaining each account role is missing (what each role does, and how they can be enabled). Sometimes a few steps are required to enable a role but that's not documented. For example, adding a delete-account role to a user also requires going to Authentication/Required actions and setting 'Delete account' to On.

    We are missing every single aspect you are pointing out here. I could not find anything at https://www.keycloak.org/docs/latest/server_admin/#_account-service.

  9. pedroigor commented on Sep 28, 2023

    @pedroigor
    Contributor

    @agagancarczyk In general, I think the open questions are:

    • Which areas can be turned on/off in the account?
    • Which areas can have specific permissions to read and write data?
    • Is the manage-account a super role that grants access to all areas in the account?
    • Are users supposed to remove manage-account role so that they can customize which areas users can access?
  10. agagancarczyk commented on Sep 28, 2023

    @agagancarczyk
    ContributorAuthor

    @agagancarczyk In general, I think the open questions are:

    • Which areas can be turned on/off in the account?
    • Which areas can have specific permissions to read and write data?
    • Is the manage-account a super role that grants access to all areas in the account?
    • Are users supposed to remove manage-account role so that they can customize which areas users can access?

    Yes @pedroigor I agree 100% Thanks!

  11. stianst commented on Sep 29, 2023

    @stianst
    Contributor

    This is not a bug, but rather a enhancement request, as the account console has never supported the fine-grained roles, but rather just manage-account role. The finer grained roles where added primarily for various Account API use-cases.

    That being said for sure it would for sure be nice to support the fine-grained roles.

    With regard to preventing adding roles that are already associated with a user from a composite role, that should be possible, and is not something we should change. A user may get a composite role through default roles, or some other composite role, then have a child role added directly, to in the future have the composite role removed, while it is still intended to leave the child role. So, don't change this behaviour for sure.

    I would close this bug, and open an enhancement request to review current roles, make sure there is a role (both view and manage) for each logical section to Account UI and API. Consider leveraging composite roles for manage-account. Then also of course support enabling/disabling sections of the UI based on what roles are available.

    A quick glance looking at roles we have now:

    • manage-account-links: Got no clue what this is. What even is a account-link?
    • Missing manage profile
    • Missing view/manage credentials
    • Missing view/manage sessions
  12. agagancarczyk commented on Sep 29, 2023

    @agagancarczyk
    ContributorAuthor

    I'm closing this issue in favor of enhancement -> #23606

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/account/apiarea/account/uikind/bug

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions