8000 KEYCLOAK-10603 adjust user-role and group-role assignments by danielFesenmeyer · Pull Request #7970 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content

KEYCLOAK-10603 adjust user-role and group-role assignments - #7970

Merged
mposolda merged 1 commit into
keycloak:masterfrom
bosch-io:fix/KEYCLOAK-10603
Sep 22, 2021
Merged

mposolda merged 1 commit into
keycloak:masterfrom
bosch-io:fix/KEYCLOAK-10603

Conversation

@danielFesenmeyer
@danielFesenmeyer danielFesenmeyer commented Apr 26, 2021 •
Copy link
Copy Markdown
Contributor

This PR adjusts user-role and group-role assignments as suggested in issue KEYCLOAK-10603: It allows assignments of roles which are already indirectly assigned.

When you are comfortable with the changes, I would adjust client- and client-scope role-mappings accordingly. I think it makes sense to have a consistent behavior for all sorts of role-mappings.

Basically, I made the following changes:

  • extend RoleMapperModel with method hasDirectRole(RoleModel), which only checks for direct assignment in contrast to the existing method hasRole(RoleModel)
  • use the new hasDirectRole method to check whether a role is in the "available" list and whether it can be assigned (previously, the hasRole method was used for this purpose)

Can someone please review my suggested changes and provide feedback? Thanks in advance :)

@stianst
stianst requested review from mposolda and pedroigor June 4, 2021 10:32
@stianst
stianst commented Jun 4, 2021
Copy link
Copy Markdown
Contributor

@mposolda @pedroigor can one of you take a look at this please?

@stianst stianst added the priority/important Must be worked on very soon label Jun 4, 2021
@pedroigor pedroigor left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@danielFesenmeyer The fix makes and sense.

@danielFesenmeyer
Copy link
Copy Markdown
Contributor Author

Hi @pedroigor,

I have integrated your suggestions into the PR:

  • Method hasDirectRole now has a default implementation delegating to getRoleMappingsStream.
  • updated the UI hints for available roles with the info that they contain effectively assigned roles which are not directly assigned.

Currently the PR only considers user-role and group-role assignments, but the same issue applies to client- and client-scope role-mappings. I would also adjust this within this PR - or should I create a separate one?

@danielFesenmeyer
Copy link
Copy Markdown
Contributor Author

Pushed a small update with a bugfix for failing integration test LDAPRoleMappingsNoImportTest.

pedroigor
pedroigor previously approved these changes Jun 16, 2021
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't you think that realm-child here is a bit confusing and susceptible to mistakes? Admins now see that role as available, but it was granted by the composite. Although indirectly.

I'm not 100% if we should deal with composite roles differently in this case. So that they are not listed as available.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@pedroigor I agree that this might be a bit confusing, at least for users who are used to the old behaviour. But otherwise it would not be possible to assign "realm-child" via the UI (at least without bigger changes to the UI).
Furthermore, there are other parts of the UI, where it is possible to assign indirectly assigned roles which are not directly assigned. There, similar mistakes might happen:

  • assigning default roles to a realm
  • assigning a child to a composite role

@pedroigor
Copy link
Copy Markdown
Contributor

@danielFesenmeyer The PR is smaller now, so perhaps we can include scope mapping too. From a reviewer's perspective, the pattern should be the same.

@danielFesenmeyer danielFesenmeyer changed the title [WIP] KEYCLOAK-10603 adjust user-role and group-role assignments KEYCLOAK-10603 adjust user-role and group-role assignments Jun 22, 2021
@danielFesenmeyer
Copy link
Copy Markdown
Contributor Author

@pedroigor, @mposolda: I've added the corresponding adjustments to scope mapping to this PR. Currently some model tests are failing, but these are also failing on master. I can rebase when master is fixed.

pedroigor
pedroigor previously approved these changes Jul 15, 2021
@pedroigor pedroigor left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@mposolda I'm approving this one but I would like to hear from you what you think. Mainly because this also touches scope mapping and introduces a new behavior.

@mposolda
mposolda commented Sep 20, 2021 •
Copy link
Copy Markdown
Contributor

@danielFesenmeyer Thanks for the PR! Sorry for the late review. The changes look good to me and I don't have any more comments to the code itself.

Just one thing: Can you please rebase to latest master? This will allow to run admin console tests in our internal testing pipeline as in theory there can be some regression in them. If you have a chance to doublecheck admin console tests in your environment, it will be beneficial as well. Thanks!

…assignments, client-scope and client "scope mappings"): allow assignments of roles which are already indirectly assigned (e.g. by composite role)

- extend RoleMapperModel with method hasDirectRole(RoleModel), which only checks for direct assignment in contrast to the existing method hasRole(RoleModel)
- extend ScopeContainerModel with method hasDirectScope(RoleModel), which only checks for direct scope mapping in contrast to the existing method hasScope(RoleModel)
- use the new hasDirectRole and hasDirectScope methods to check whether a role is in the "available" list and whether it can be assigned (previously, the hasRole method was used for this purpose)
- add hint to UI that available roles contain effectively assigned roles which are not directly assigned
- adjust and extend tests
@danielFesenmeyer
Copy link
Copy Markdown
Contributor Author

@mposolda Thanks for the review. I'll rebase to master and also doublecheck admin console tests - will let you know when finished.

@mposolda
Copy link
Copy Markdown
Contributor

@mposolda Thanks for the review. I'll rebase to master and also doublecheck admin console tests - will let you know when finished.

Thanks!

@danielFesenmeyer
Copy link
Copy Markdown
Contributor Author

@mposolda: Rebased to a commit from yesterday. Cross-DC tests have failures, but these are the same as on master ("org.jboss.arquillian.container.spi.client.container.LifecycleException: Infinispan server startup timed out").
Admin console tests all worked fine (with latest chrome in headless mode).

@mposolda
Copy link
Copy Markdown
Contributor

@danielFesenmeyer Thanks, trying pipeline build in our CI environment and will merge once it pass.

@mposolda mposolda left a comment
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@danielFesenmeyer Thanks! I've checked in our pipeline that cross-dc, cluster and admin console tests are fine. Just for the reference:
https://keycloak-jenkins.com/job/universal-test-pipeline-server/788/
https://keycloak-jenkins.com/job/universal-test-pipeline-server/791/

@mposolda
mposolda merged commit 3392245 into keycloak:master Sep 22, 2021
@danielFesenmeyer
Copy link
Copy Markdown
Contributor Author

Thanks to you maintainers for reviewing and merging :)

@danielFesenmeyer
danielFesenmeyer deleted the fix/KEYCLOAK-10603 branch September 23, 2021 07:47
@wwwy3y3
wwwy3y3 commented Nov 25, 2021
Copy link
Copy Markdown

hi @mposolda @pedroigor @stianst

Thanks for the review on this PR, which is really helpful in our use case.

Just want to ask if there's an estimated time of the 16.0.0 release (I assume it would be the next release version, which includes this patch ?) since it's been 3 months since the last release.

Thanks for the hard work on Keycloak :)

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

Labels

priority/important Must be worked on very soon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

0