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

Skip to content

Use back keycloak-js instead of initiate login in the backend for account#42035

Merged
jonkoops merged 1 commit intokeycloak:mainfrom
rmartinc:issue-40463
Aug 26, 2025
Merged

Use back keycloak-js instead of initiate login in the backend for account#42035
jonkoops merged 1 commit intokeycloak:mainfrom
rmartinc:issue-40463

Conversation

@rmartinc
Copy link
Contributor

@rmartinc rmartinc commented Aug 21, 2025

Closes #40463

After checking this I think the only way of doing this OK without changing things a lot is going back and use keycloak-js normally again. If I understood this correctly, the initial issue #31469 was reported because the console was displayed empty, and the login was requested later when the login was required for the first request (401). This PR does the following:

  • The backend does not initiate the login. This part is removed because it's a mess. This is the first login and then the account console uses keycloak-js to login again (automatically now because cookies are in place), but it was a second round-trip in events. The JS part cannot use the state or code verifier generated by the backend. It makes no sense.
  • The applications now in ui-shared always initiates the login if not already authenticated. This way nothing is displayed (just the spinner) and if the redirect is needed, from the spinner you go to the login page. Nothing is shown except the spinner if you are not logged in. The shared part is used for both consoles (admin and account).
  • The problem is that there are a lot tests that thinks that there will be an automatic redirect for the account console. As keycloak-js is used we need a real browse (firefox or chrome) to execute the JS needed to login. I have changed those tests to use other thing instead of the account console.
  • The AccountConsoleTest is the only test that really checks the account functionality This one is moved to the forms package to be used with firefox and chrome. The scopes are correctly respected. The only little difference is that the keycloak-js always adds openid, but I think that this is OK.
  • I have also changed the error representation. The current setup shows anything in the error_description returned. The only error accepted now is a JS Error or the error generated bye keycloak-js. As the error is standard I have provided the translations for it, and only the standard errors are displayed. Other unknown error uses always the same message.

It's a draft for now. Because maybe you see another approach (but I really don't see anything better than this).

@mposolda mposolda requested a review from pedroigor August 21, 2025 11:53
@jonkoops
Copy link
Contributor

@rmartinc I am moving this out of draft in your absence, I agree with the approach here. I'll have some other reviewers check this out as well.

Copy link
Contributor

@pedroigor pedroigor left a comment

Choose a reason for hiding this comment

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

I agree about the mess. The discussions at that time were basically changing UIs vs backend, whereas the UI was, in theory, too hard to change in order to avoid rendering the React app when users are not yet authenticated.

If we are still handling errors properly and the spinner is shown instead of initing the React app, LGTM.

@jonkoops jonkoops merged commit 360ff70 into keycloak:main Aug 26, 2025
76 checks passed
rmartinc added a commit to rmartinc/keycloak that referenced this pull request Sep 8, 2025
rmartinc added a commit to rmartinc/keycloak that referenced this pull request Sep 8, 2025
rmartinc added a commit to rmartinc/keycloak that referenced this pull request Sep 8, 2025
mposolda pushed a commit that referenced this pull request Sep 8, 2025
…ount (#42035)

Closes #40463

Signed-off-by: rmartinc <[email protected]>
(cherry picked from commit 360ff70)
mposolda pushed a commit that referenced this pull request Sep 9, 2025
…ount (#42035)

Closes #40463

Signed-off-by: rmartinc <[email protected]>
(cherry picked from commit 360ff70)
rmartinc added a commit to rmartinc/keycloak that referenced this pull request Sep 17, 2025
rmartinc added a commit to rmartinc/keycloak that referenced this pull request Sep 17, 2025
rmartinc added a commit to rmartinc/keycloak that referenced this pull request Sep 17, 2025
rmartinc added a commit to rmartinc/keycloak that referenced this pull request Oct 29, 2025
PeterGFernandez pushed a commit to PeterGFernandez/keycloak that referenced this pull request Jan 19, 2026
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.

Login to Account Console produces two consecutive LOGIN events

3 participants