-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Azure AD B2C bad request when redirecting / using cy.origin() #25806
Comments
[UPDATE] - This has nothing to do with query params. We found that the params are added by the SSO provider. Nevertheless, there is still an issue here. When doing the login manually or with But when doing it without the Maybe the proxy of cypress is not proxying well the request |
@mmonteiroc we have encountered a similar issue. We also use Azure AD B2C. Everything works fine for localhost and cy.origin wrapped around B2C SSO page. But when we open the app on an actual domain for example app.domain.xyz and we have our B2C login page on login.domain.xyz, we can't use cy.origin (the same super domain) and we get the AADB2C90255 B2C error (_The claims exchange specified in technical profile '{0}' did not complete as expected. You might want to try starting your session over from the beginning). I have tried almost everything, still without success :/ |
Hey @mmonteiroc and @sebastiandenis - could you please try updating to Cypress 12.7.0? We included some bugfixes related to session, origin, and cookies that may resolve your issues: https://docs.cypress.io/guides/references/changelog#12-7-0 |
@flotwig @mmonteiroc I've tried with the 12.7.0 version, the same result. But today we've made a little test. We've run the same app on a different super domain, so we could use cy.origin(), and it worked. It looks like the whole magic for Azure AD B2C to work fine is somewhere in the cy.origin() method. Scenario 1: app.domain.xyz -> login.domain.xyz (can't use cy.origin(), the same super domain - B2C doesn't work). Any ideas on how to force Cypress to let me use cy.origin between different subdomains but the same super domain? |
Same behaviour in our side @flotwig @sebastiandenis We face the issue only when using same "root domain" ( which is our case so we need to keep it like so ). When we are outside of the same domain ( localhost for instance ), and we have to use cy.origin works perfectly fine ! /ping @mjhenkes as I see that @flotwig removed it self and added you :) |
You guys could try two things:
Overall i think we need to address this ourselves to provide a more user friendly experience but that could take some time. |
Will try that feature. But if you see my example code, i have the code already adapted for CI, and the issue is that fails when not using the cy.origin() |
@mjhenkes I've tried with the skip domain injection option, but I can't make it work, Cypress fails with the error message:
I've tried with different configurations (including visiting domain app.domain.xyz before using cy.origin) but the same result. For now, as we have a dedicated environment for E2E tests, we want to test the solution that our app is on a different port than the B2C login page: app.domain.xyz:12345 -> login.domain.xyz - as we've observed it may work (Cypress doesn't complain about the same super domain). |
@mmonteiroc @sebastiandenis, could you guys give me a brief overview of your auth flow for both local and in ci? I've been trying to figure it out from the comments above but i'm getting lost somewhere. I don't need any specifics, just the general flow.
Does your site user auth tokens or cookies? |
So on our side the flow is the following:
The problem on our side, is that when we dont use the If you need, I am happy to run the tests with some logs enabled and provide you some data to help debug ? Let me know please. |
@mjhenkes FYI, this flow mentioned above is the same one in local / ci . The only difference is that in local, the redirections happen between |
@mjhenkes similar on our side. We have an Angular app that uses angular-auth-oidc-client (oauth code flow) + Azure AD B2C. We have our app available on: app.domain.xyz Everything works fine when we run Cypress and it tests the app running on localhost (and using cy.origin):
When we run tests with the app that is available on app.domain.xyz and we remove cy.origin (because of the same super domain Cypress error):
I believe that it's a similar case to @mmonteiroc but we have a little different B2C configuration. |
@sebastiandenis, @mmonteiroc , When you tried I put together an example below to describe why. Hope it helps. const login = (username, password) => {
// without experimentalSkipDomainInjection login.domain.xyz and app.domain.xyz are same super origin and cy.origin will error.
cy.origin(
loginOrigin,
{
args: {
username,
password,
}
}, ({username, password}) => {
cy.visit('/') // visiting inside the cy.origin block prevents top from being set. This visit redirects to login.domain.xyz. Top would have been set to login.domain.xyz.
cy.get('username', { timeout: 5000 }).should('be.visible').type(username, { log: false });
cy.get('password').type(password, { log: false });
cy.get('submit').click(); // redirects back to originating origin (localhost or app.domain.xyz)
cy.wait(100) // may or may not be needed, wait a touch on the site to ensure tokens are setup if not using cookies.
})
}
it ('authenticates', () => {
// base url is set, causing top to be set to either localhost or app.domain.xyz
login(username, password)
// You're now back at '/' in localhost or app.domain.xyz
}) |
Hi ! @mjhenkes The config is the following one With the property you provided, is true that we dont have to differentiate between using or not the cy.origin. But apparently this was not the solution to the problem. The code used is the following:
|
@mjhenkes please let me know if i can provide u any logs that might help you investigate this :) |
@mmonteiroc, could you compare the cookies/tokens sent for a successful auth outside of cypress against an unsuccessful auth inside of cypress? Anything different about the requests could help. Maybe we're loosing cookies or mangling them? |
@mjhenkes I will try to investigate this. I may take 1 day to come back to you, but will do it as soon as possible :) |
I've the exact same setup and problem as @sebastiandenis: my Angular app is hosted on |
@mjhenkes @AtofStryker |
Hi all, I have the same issue. I've done the suggested test and obtained the same results as @mmonteiroc. There is no difference in the request. |
@mmonteiroc interesting. I wonder if there is something additional going on in the proxy layer that might tell a different story. When you compared the request, did you do so in devtools? Would you be able to send any of the logs if you set It seems like the next steps here, besides sending the logs, might be to get a minimal reproduction up and running. I don't have a B2C account, but might be able to set one up easily. Any idea how we can create one similar to your set up without a ton of config? If we can do that, and parity hosting, I would think this would be fairly reproducible. |
Im sorry, but seems I cannot manage to get these logs in the output of the terminal. And To run the test, and the only logs I see are these ones:
|
As stated above the fix did not help for me, so I created another issue: |
We have exactly the same problem. It blocks us from upgrading cypress (it worked in the previous versions). I managed to find out that it stopped working in version 10.10.0 (10.9.0 is the last working version) |
Any update on the change @AtofStryker? Would love to get this working on current 13.2.0 version |
@JKetelaar no updates as of yet |
Are you planning to publish the change soon? Currently it's blocking us to use Cypress, and the release provided by your commit is using an old version at this point (v12 instead of v13) |
In our case, we switched back to v.10.9.0, as @akotynski states this was the last working version. @AtofStryker , do you think is possible to publish a new build with the same fix as here, on top of the latest version - 13.3 ? It will be really helpful to avoid using such an old version. Thank you! |
@JKetelaar That's what makes this a bit challenging, as we really don't have a fix for this but a diagnostic binary that gives us a really good idea as to what the problem is.
@madalinbucur152 I don't think this is a permanent solution by any means but yes I can take care of that. I will be out for some time and will return to triaging issues in 2024, but I will take care of that now and post the link to the binaries The branch https://github.com/cypress-io/cypress/compare/same-origin-match-for-cookie-jar?expand=1 should now be based off of |
Hi, We are facing issue while running cypress tests on application with custom domain. When the application URL has azurewebsites.net, we are not seeing any issue and able to login to the application. When there is custom domain in the URL, after logging in we are getting blank screen and it redirects to the following URL |
@AtofStryker We were relying on the previous build added here which expired these days. Can we have a new build with the same fix? Thank you! |
Hi @madalinbucur152. Sorry for the delayed response as I have been on leave for a few months. I kicked off a build based off |
Hi @AtofStryker! Thanks for the fix! Would it be possible to have a permanent fix for this issue? It is quite unpleasant that once at 60 days (when pre-release build is not available anymore) to have our tests fail in the pipeline and be forced to downgrade to an older version - 10.9.0 - (which is the last working version) until a new pre-release build is available. |
Hi @CristinaVeronica. I completely understand as that does sound painful. Unfortunately we are unable prioritize a fix at this time. We are always welcome to taking contributions, but this fix likely means making changes to the cookie behavior around Cypress superdomain handling which could be a breaking change. |
Hi we have exactly the same problem. It blocks us from upgrading new cypress versions I checked on version 13.6.5 any solution for this issue ? |
Hi @AtofStryker can you please rebuild the patch as the old link retention policy kicked in. |
its currently building on c7af4ad |
Hi, I also met this issue and still need to use cypress 10.7.0. Are there any plans to unblock cypress updates? |
One workaround: We added a second login option (Login via email link) to our page and I was able to implements tests. Fill out email, calling mails via imap, klick the email link and voila, I'm logged in. Its a bummer, that this is still an issue in cypress. |
@AtofStryker me again with a request for a new build. |
Ill get this taken care of today |
currently building on f4a46eb |
@AtofStryker we also use this image, starting this afternoon its giving a 404, is it possible to make a new build? |
@BartDeKrab just kicked off and is building on 1b69a11 |
Any update on this issue? We are also facing it with the same conditions described above, app in |
No updates as of now. We are at a fork in the road where a change of this type is likely a breaking change, which is currently unplanned. But fixing this issue almost goes hand in hand with #29590, which seems like is going to be unavoidable moving forward. The fog on the path forward is still somewhat cloudy. |
@AtofStryker Hello again, we are dependent on this, can you please make another build as the retention policy kicked in again? |
@Ognengineer build is running on cd5ec48 |
@AtofStryker Hey, can you please make another build? Thanks! |
Current behavior
We are trying to do a login with cypress, and we tried to use the "cy.origin" command. In local this worked well, as the domain of the login was a complete different one.
Once we launched this in the pipeline, started complaining cypress that the "super domain" was the same one ( same error as this issue ).
As cypress identifies the login domain as the same domain, we assumed that then we could use the cypress commands directly in that page, so we did the following condition so that the code would be executed with origin or without depending of the environment:
Problem comes that when we are doing the login in the CI ( not using the cy.origin ), one response of loading a page returns a 400 ( usually returns a 302 that page - With cy.origin or by normal usage of the login )
Same code executed in localhost, and using the cy.origin works just perfectly
Desired behavior
That the code works the same with or without origin
Test code to reproduce
Provided in the description
Cypress Version
12.5.1
Node version
18.13.0
Operating System
Windows 10 19042.2486
Debug Logs
No response
Other
SSO for the login used is
Azure AD B2C
Frontend application is
Angular with @azure/msal-angular
The text was updated successfully, but these errors were encountered: