Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default client scopes of standard clients do not get intialized on realm import causing 'Forbidden' error in the account console #10021

Open
gunterze opened this issue Feb 5, 2022 · 3 comments

Comments

@gunterze
Copy link

gunterze commented Feb 5, 2022

Describe the bug

When I create a new realm, I only have to enter the name and the standard clients are created automatically and all available Default and Optional Client Scopes are assigned for each client.

When I export the realm (without group and roles and clients) , delete it and import it again, then the standard clients are created as well, but this time the Assigned Scopes are empty, which causes the 'Forbidden' error in the account console.

s. KEYCLOAK-16682

Since version 12.0.1

Version

18.0.0

Expected behavior

created-realm

Actual behavior

imported-realm

How to Reproduce?

  1. create realm
  2. export realm (without group and roles and clients)
  3. delete realm
  4. import realm

Anything else?

If I export the realm without group and roles, but with clients, delete it and import it again, then the Assigned Scopes for standard clients get initialized, but now they did not get all of their Roles assigned, e.g.:

Expected Roles:

created-realm-roles

Actual Roles:

imported-realm-roles

@kami619
Copy link
Contributor

kami619 commented Nov 15, 2022

@hmlnarik

Apologies on the delay in getting to this issue.

I was able to reproduce part of the issue and can confirm the issue with Roles being truncated from default clients is not reproducible anymore.

Here is the reproduce steps in a video.

Issues resolved: The roles associated with each default client after the export and re-import of the realm are unchanged, which you can also observe in the video.

2022-11-14.20-04-24.mp4

Partial Issue observed: The number of client scopes associated with each default client seems to be reduced to only one client scope after the export and re-import as shown below.

Before:
default_client_scopes_realm

After:
client_scopes_after_partial_import_realm_create

@hmlnarik hmlnarik assigned ahus1 and unassigned kami619 Mar 2, 2023
@ahus1
Copy link
Contributor

ahus1 commented Mar 7, 2023

Triage result: The partial export via the UI contains the client scopes. During import those client scopes are re-imported, but this doesn't trigger any logic to assign those scopes to the clients.

As the export doesn't contain the clients, it the import can't figure out what to do here, as it doesn't know which client should have which client scope assigned. At the same time the import create some essential clients, but doesn't assign them any client roles.

Similar pattern applies for roles.

To have the clients re-created with the same scopes as in the original realm and with the same roles, create a partial export with roles and clients.

Another way I found is to create a partial export without clients and roles, then manually delete the clientScopes. This will trigger the logic to re-create the client scopes and also assigns them to the clients. In my tests it also setup the client roles as expected.

@hmlnarik - with the behavior of the partial import and export being complex and not documented, I suggest to remove the two options to skip roles/groups and clients, and to always export them.

@keycloak-github-bot
Copy link

Due to the amount of issues reported by the community we are not able to prioritise resolving this issue at the moment.

If you are affected by this issue, upvote it by adding a 👍 to the description. We would also welcome a contribution to fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 📤 Todo
Development

No branches or pull requests

6 participants