Skip to content
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

okta_auth2.middleware.OktaMiddleware redirecting to login page #33

Open
silver8ack opened this issue Jun 20, 2023 · 5 comments
Open

okta_auth2.middleware.OktaMiddleware redirecting to login page #33

silver8ack opened this issue Jun 20, 2023 · 5 comments

Comments

@silver8ack
Copy link

silver8ack commented Jun 20, 2023

I'm having trouble with getting the Middleware to work.

I can successfully login via Okta and access the Django admin site, and other decorated views. However, this is while using the backend WITHOUT the okta_auth2.middleware.OktaMiddleware middleware. Once I enable okta_auth2.middleware.OktaMiddleware in MIDDLEWARE, all login attempts just redirect back to the login page.

I need some help determining where to look for issues. As I said, the auth works fine without the middleware in place, so I believe all configs are correct. Also okta auth is working 100% as users can login, groups are retrieved, etc.... For some reason, when enabling the middleware, it just doesn't work.

Without the middleware in place I need to override the admin login form to redirect to Okta, which I can do. However, I'd rather the middleware just do what it's supposed to.

Any tips would be greatly appreciated.

There are no errors anywhere, so not much to show right now.

@silver8ack silver8ack changed the title Any additional info for configuring Super User? okta_auth2.middleware.OktaMiddleware redirecting to login page Jun 22, 2023
@iblankJC
Copy link

Getting the same issue

@kimbuckley
Copy link

I have the same issue as well.

@tejon-melero
Copy link

I ran into the same issue, it started to happen after a Django upgrade (Django versions 4.1 and lower were working fine Django versions 4.2 and higher stopped working)

I created a PR that fixes this looping redirect issue and makes it so that session tokens are properly stored again:
#34

@kaskichandrakant
Copy link

kaskichandrakant commented Apr 11, 2024

I was also facing the same issue and from your solution PR I tried to understand where the problem could be and got to know its because of one /.

solution that worked for me is similar to your PR but on the okta setting side. Instead of removing the / from configured URLs I updated the okta configuration to add extra / in callback url.

so my redirection url was http://{HOST}/oauth2/callback/ instead of http://{HOST}/oauth2/callback in okta configuration. and no need to change the library code and PR.
Screenshot 2024-04-11 at 1 50 16 PM

hope it saves someone's time :)

@AzMoo
Copy link
Owner

AzMoo commented Jul 1, 2024

Hey sorry, I haven't been using Django now for a few years and this is super low on my priority list. I will try and find some time over the next week or two to catch up on it all.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants