Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@rmartinc
Copy link
Contributor

Closes #25219

This PR modifies the whoami endpoint to return forbidden/403 in two situations: the azp or issuedFor is not security-admin-console (we are ensuring this endpoint is just used for the admin console); the user mapped to the token has no pemissions/access to the requested realm (previously it returned a response with empty realm access). This is what was decided when the issue #25219 was discussed inside the team.

Besides the test AdminConsolePermissionsCalculatedTest was removed because it makes no sense since the whoami endpoint was changed to just return the access for one realm (#21553). I have added some tests in the class AdminConsoleWhoAmILocaleTest. Maybe we can rename that class because now it's testing more than just the locale part, but I finally didn't do it. If you prefer to call it AdminConsoleWhoAmITest or similar just let me know.

Copy link

@keycloak-github-bot keycloak-github-bot bot left a comment

Choose a reason for hiding this comment

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

Unreported flaky test detected, please review

@keycloak-github-bot
Copy link

Unreported flaky test detected

If the flaky tests below are affected by the changes, please review and update the changes accordingly. Otherwise, a maintainer should report the flaky tests prior to merging the PR.

org.keycloak.testsuite.account.AccountRestServiceTest#updateConsentForClientWithPut

Keycloak CI - Java Distribution IT (windows-latest - temurin - 19)

java.lang.AssertionError
	at org.junit.Assert.fail(Assert.java:87)
	at org.junit.Assert.assertTrue(Assert.java:42)
	at org.junit.Assert.assertTrue(Assert.java:53)
	at org.keycloak.testsuite.account.AccountRestServiceTest.updateConsentForClientWithPut(AccountRestServiceTest.java:1465)
...

Report flaky test

org.keycloak.testsuite.account.AccountRestServiceTest#createConsentForClientWithPut

Keycloak CI - Java Distribution IT (windows-latest - temurin - 19)

java.lang.AssertionError: 
type
Expected: is "GRANT_CONSENT"
     but: was "UPDATE_CONSENT"
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
...

Report flaky test

org.keycloak.testsuite.account.AccountRestServiceTest#createConsentForClient

Keycloak CI - Java Distribution IT (windows-latest - temurin - 19)

java.lang.AssertionError: 
type
Expected: is "GRANT_CONSENT"
     but: was "UPDATE_CONSENT"
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
...

Report flaky test

@mposolda mposolda self-assigned this Apr 22, 2024
Copy link
Contributor

@graziang graziang left a comment

Choose a reason for hiding this comment

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

LGTM!

Copy link
Contributor

@mposolda mposolda left a comment

Choose a reason for hiding this comment

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

@rmartinc @graziang Thanks for the fix and review!

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Restrict the access to 'whoami' endpoint for tokens issued for the admin console client

3 participants