question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cy10 multi domain: redirect triggered keycloak login form is unresponsive

See original GitHub issue

Current behavior

Dear Cypress Team,

first congratulations to the release of Cy10 was really looking forward to the multi domain support 🚀 and I am happy to report that it kinda works as expected 😃 meaning we are finally about to drop kcFakeLogin https://github.com/Fredx87/cypress-keycloak-commands

However, there seem to be some remaining edges not yet resolved: For us the keycloak login form is unresponsive when having the login page triggered by a redirect.

Desired behavior

For now the workaround is sufficient to pass the login to test features which require to be logged in Nevertheless, the current behavior blocks us to fully abandon kcFakeLogin because we still need it to make sure that the Keycloak login can be triggered and is working as expected.

So we would expect that the keycloak login form still remains responsive when triggered by a redirect and not by a button.

Keep up the good work ✌️

Test code to reproduce

Cypress.Commands.add("login", (user, redirect) => {
 const baseUrl = "http://localhost:4000";
 cy.visit(`${baseUrl}/#/${redirect}`)
 cy.origin(
     "https://sso.xy.dev",
     { args: { user } },
     ({ user }) => {
       cy.get("#username")
         .type(user)
         .get("#password")
         .type(Cypress.env("auth_password"));
       cy.get("#kc-login").click();
    }
   );
   cy.visit(`${baseUrl}/#/${redirect}`);
 });

Timed out retrying after 4000ms: Expected to find element: #username, but never found it.

Workaround: Trigger login form by login button

Cypress.Commands.add("login", (user, redirect) => {
 const baseUrl = "http://localhost:4000";
 
 // redirect triggered keycloak login window is unresponsive,
 // thus we need to trigger the login using the login button
 cy.visit(baseUrl);
 cy.get(".header-right > :nth-child(2)").click();

 cy.origin(
     "https://sso.xy.dev",
     { args: { user } },
     ({ user }) => {
       cy.get("#username")
         .type(user)
         .get("#password")
         .type(Cypress.env("auth_password"));
       cy.get("#kc-login").click();
    }
   );
   cy.visit(`${baseUrl}/#/${redirect}`);
 });

Cypress Version

10.1.0

Other

Tested Browsers:

  • Electron v100
  • Chrome v98

relevant versions of the package.json

  • react: “^16.14.0”,
  • keycloak-js: “^18.0.0”,
  • cypress: “^10.1.0”,

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
AtofStrykercommented, Jun 15, 2022

Hey @AtofStryker thank you for having a look into and setting up a reproduction repo so quickly. I have pulled it and can confirm that this is exactly the same bug we observe in our react app as well.

Just for completeness, in order to have the expected tests passed I had to modify the following:

README: ~*Set Valid Redirect URIs to http://localhost:8081/*~ Set Valid Redirect URIs to https://www.keycloak.org/app/* Set Web Origins to *

keycloak.cy.js: ~cy.get(‘#user-details’).contains(‘my user’)~ cy.get(‘#user-details’).contains(‘myuser’)

Good luck with fixing the issue ✌️

@IvoLeist perfect. I will update the readme and test file with your suggestions to make sure everything runs as expected. Thank you for pulling that down and verifying it!

1reaction
IvoLeistcommented, Jun 15, 2022

Hey @AtofStryker thank you for having a look into it and setting up a reproduction repo so quickly. I have pulled it and can confirm that this is exactly the same bug we observe in our react app as well.

Just for completeness, in order to have the expected tests passed I had to modify the following:

README: *Set Valid Redirect URIs to http://localhost:8081/* Set Valid Redirect URIs to https://www.keycloak.org/app/* Set Web Origins to *

keycloak.cy.js: cy.get(‘#user-details’).contains(‘my user’) cy.get(‘#user-details’).contains(‘myuser’)

Good luck with fixing the issue ✌️

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cy10 multi domain: redirect triggered keycloak login form is ...
However, there seem to be some remaining edges not yet resolved: For us the keycloak login form is unresponsive when having the login...
Read more >
OpenID with keycloak, infinite redirect loop after successful ...
The thing is, I can successfuly redirect to my Keycloak login page, but when it redirects to the url specified after successful login, ......
Read more >
How can I redirect the WordPress default login to a custom ...
The easiest method I know of to create a custom WP login page is to use the WPS Hide Login plugin. It's a...
Read more >
Securing Applications and Services Guide - Keycloak
It allows you to redirect unauthenticated users of the web application to the Keycloak login page, but send an HTTP 401 status code...
Read more >
Search Results - CVE
For organizations with System for Cross-domain Identity Management(SCIM) ... Notice the vulnerability cannot be triggered by web requests in Tapestry code ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found