Skip to content

KEYCLOAK-16832: using realm name instead of id - #7724

Merged
pedroigor merged 1 commit into
keycloak:masterfrom
stummb:KEYCLOAK-16832
Jan 29, 2021
Merged

pedroigor merged 1 commit into
keycloak:masterfrom
stummb:KEYCLOAK-16832

Conversation

@stummb

@stummb stummb commented Jan 18, 2021

Copy link
Copy Markdown
Contributor

in order to get localization texts

in order to get localization texts

@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.

@stummb This is a valid fix.

I'm also dealing with it on #7712. There, I'm basically returning both name and id when using a non-master admin user.

However, your steps in KEYCLOAK-16832 to reproduce the issue may be missing assgining the view-realm role. Otherwise, you should get a 403 when reaching that endpoint.

Could you check if this is true?

@hmlnarik hmlnarik 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.

@stummb Thank you for the fix! I can see this is a valid change, however the way it is fixing is confusing. The parameter names should be consistent wherever possible, could you please fix it?

currentRealm = Current.realm.id;
translateProvider.translations(locale, resourceBundle);
RealmSpecificLocalizationTexts.get({id: currentRealm, locale: locale}, function (localizationTexts) {
RealmSpecificLocalizationTexts.get({id: Current.realm.realm, locale: locale}, function (localizationTexts) {

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.

This is confusing. Either the API is using realm id - then the original code is correct, or the API is using unique realm name (realm) - then this fix should be accompanied with the change in RealmSpecificLocalizationTexts that renames id to realm for the sake of consistency.

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.

services.js contains 141x the line "realm : '@realm'" and 7x the line "id : '@realm'". I agree that should be fixed, but I am not confident enough to do that as backend dev without angular knowledge :-)

@pedroigor pedroigor Jan 26, 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.

I don't think there is anything to change. Otherwise, we would be asking for refactoring (IMO, not really the scope here) other parts of the admin console too.

API-wise, there is a weird behavior where the id might not be returned but the name. Something I also catched in #7712.

From my side, looks good.

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.

Yup, this should have been caught earlier, when introducing the first inconsistency. I don't see this as a blocinkg issue, rather a reminder that we should be more careful when doing PR reviews.

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.

@hmlnarik True, thanks Hynek. Hope we improve test coverage of the admin console. Something I think is being considered from day one on the new account console. Mainly specific use cases like this one (admin permissioning).

@hmlnarik hmlnarik added area/ui kind/bug Categorizes a PR related to a bug labels Jan 18, 2021
@stummb

stummb commented Jan 19, 2021

Copy link
Copy Markdown
Contributor Author

However, your steps in KEYCLOAK-16832 to reproduce the issue may be missing assgining the view-realm role. Otherwise, you should get a 403 when reaching that endpoint.

I did that with the master admin user, who has the view-realm role. Note that KEYCLOAK-16832 was not opened by me, I just felt that it was the same bug. In our setup we have several realms where id = realm name, and one where both values differ from eachother. When switching to this realm, we get the error in the ticket. Also when reloading the page. However, clicking browser back button gives uns the overview page of the realm. When I go to the Localization tab then, I see the /realms/localization/en url being called with realm name instead of id.

@pschichtel

Copy link
Copy Markdown
Contributor

So what is preventing this from being merged now? I'm facing the same issue.

@ssilvert
ssilvert requested a review from hmlnarik January 26, 2021 19:36
@ssilvert

Copy link
Copy Markdown
Contributor

@hmlnarik Are you ok with merging this?

@hmlnarik

Copy link
Copy Markdown
Contributor

@hmlnarik Are you ok with merging this?

Yes. https://issues.redhat.com/browse/KEYCLOAK-17003 was introduced as a follow-up task.

@hmlnarik

Copy link
Copy Markdown
Contributor

@ssilvert Before merge, could you please check which of the PRs contains the correct fix: this one or #7707 (the latter includes also fix in the condition).

@maunzCache

Copy link
Copy Markdown

@hmlnarik Would it be possible to have a backmerge for 12.x ? This issue is not huge but my team is considering to skip Keycloak 12 until the next major which is likely to come end of february/march.

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

Labels

kind/bug Categorizes a PR related to a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants