-
-
Notifications
You must be signed in to change notification settings - Fork 90
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
Add-PodeAuth -SuccessUseOrigin doesn't redirect to requested site #1007
Comments
I just ran into what I think is this bug today. When I'm using azureAD for auth with -successuseorigin it redirects back to http://localhost:8081/oauth2/callback?code= Also on pode 2.7.1 and windows powershell 5.1 |
Hey @thekamilpro, @robertfshort, I think I might have just fixed this one as a part of #1036 - as redirecting now seems to work OK for me. Would either of you be in a position to test what's currently in the develop branch, and see if redirecting now works for yourselves? If you can't get develop to build locally, I believe changing the line locally at Pode/src/Private/Authentication.ps1 Line 1345 in 8aa7c2b
if ($Success.UseOrigin) { should work 🤔
Thanks! 😄 |
I'm having the same issue as @thekamilpro while trying to use the -SuccessUseOrigin switch with Add-PodeAuth. I also tried modifying line 1345 of Pode/src/Private/Authentication.ps1:
However, the issue persisted. Platform
|
Hey @thekamilpro, @robpitcher, I might have found the issue: the redirecturl cookie wasn't being set when the redirect for oauth occurred. Along with the change stated in my previous comment, you'll also need to add the following lines: if ($auth.Success.UseOrigin -and ($WebEvent.Method -ieq 'get')) {
$null = Set-PodeCookie -Name 'pode.redirecturl' -Value $WebEvent.Request.Url.PathAndQuery
} to just before this line (still within the Pode/src/Private/Authentication.ps1 Line 1182 in 8aa7c2b
I was able to reproduce the issue, and with the above lines the redirecting to the originating page now works for me. If you're able to test this, let me know what happens 😄 |
So I'm now seeing the pode.redirecturl cookie is being set, but it still doesn't redirect as expected. I tested a workaround by adding some logic to the scriptblock of route /oauth2/callback to handle the redirect and this worked:
|
Hi @robpitcher, That's interesting, because that's the same logic Pode uses to do the redirecting directly within authentication 🤔 Are you able to show more of your script - mostly the lines where you add the auth/scheme? |
@Badgerati yes, here's the full auth/scheme setup:
|
I might have found something, what happens if you set |
So I tested this and the result was that I was redirected to the SuccessUrl regardless of origin. Tested this on Pode v2.8.0. |
Looks like this issue still exists in 2.10.1 I tried setting up a custom callback as @robpitcher suggested, but get a 500 error. Did the change to set the redirection cookie ever make it into the base version of PODE or do I need to go make the changes @Badgerati noted above? Alternatively is there something I can add to my code to set that cookie rather than having to modify the base PODE files?
|
Hi @robertfshort, The redirect code above wasn't added in, I actually thought I had! The authentication logic has changed quite a bit since the line changes referenced above were suggested, so I'll need to go back and see if anything needs re-implementing. |
Describe the Bug
Experienced this particular issue while using Azure AD, single sign on, global authentication.
The bug affects only the very first login (where I guess there's no session, or it expired). When accessing a specific page, e.g. https://example.com/cat-facts after successful authentication redirects to https://example.com/ - so user would either need to manually open desired page, or click link second time.
Steps To Reproduce
Expected Behaviour
Ideally, Pode would "remember" originating site, redirect to it after successful authentication.
Going to https://example.com/cat-facts would in fact redirect to https://example.com/cat-facts after initial successful authentication.
Platform
The text was updated successfully, but these errors were encountered: