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

Authenticating for a different domain using SAML_ALLOWED_HOSTS fails #335

Open
shadowbrush opened this issue Jun 9, 2022 · 4 comments
Open
Labels

Comments

@shadowbrush
Copy link

We are trying to configure our SSO SP for subdomains other than the one that receives the AssertionConsumerService POST. For example:

SAML_ALLOWED_HOSTS = ['b.example.com']
SAML_CONFIG = { 'service': { 'sp': { 'endpoints': { 'assertion_consumer_service': [('https://a.example.com/saml2/acs/', saml2.BINDING_HTTP_POST)]}}}}

We start the login with:

https://a.example.com/saml2/login/?next=https://b.example.com/dashboard&idp=idp-id

This performs the SSO correctly and forwards the user to https://b.example.com/dashboard as expected. But the user is not logged in there. They are logged in at https://a.example.com/dashboard.

It appears that the cookies are always saved to a.example.com.

Any ideas how to fix this? Thanks!

@peppelinux
Copy link
Member

wow, I never had an idea like this in my life!

You can do something like this using a modified (inherited) samesite middleware

as you can see, for security reason, the session cookie domain is fixed here
https://github.com/IdentityPython/djangosaml2/blob/master/djangosaml2/middleware.py#L73

i suggest you, if you want in this way, to filter over a list of allowed domains before settings the cookie with the request domain dynamically

No, I want implement this in the mainline but I appreciate the "original" ideas like this one :)

@shadowbrush
Copy link
Author

Thanks for your quick response, Giuseppe! If my company decides to add support for target domains I'll provide a PR for it.

@shadowbrush
Copy link
Author

@peppelinux Here is the PR: #336

@peppelinux
Copy link
Member

hi @shadowbrush, do you ahve any update on this issue?

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

No branches or pull requests

2 participants