-
Notifications
You must be signed in to change notification settings - Fork 75
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
SLO support using back channel #60
base: main
Are you sure you want to change the base?
SLO support using back channel #60
Conversation
I'm currently working on implementing a test, which, like the tests in #61, works without the LOGOUT_SESSION_KEY stuff. |
@egroeper thanks for your work. I think this work is in-scope for this package. Here are some thoughts:
|
I will try that.
I'm with you. I first tried with the latest release, but it didn't work out. Using the current master worked. By just looking through the commit history of spyne, I currently can't see a reason for that. I will reinvestigate. |
a150875
to
381c4e8
Compare
This now works with spyne 2.12.14 |
381c4e8
to
c885a56
Compare
Made this feature optional and added some tests. Should be okay now. Anything else to do? |
1f75792
to
a51e433
Compare
I now improved / finished the SOAP modelling and reactivated xml input validation. Some documentation would be nice. Should I try to extend the Optional section of the README or do you think this would better fit in a separate file? |
@egroeper Either way is fine with the documentation. You could try extending the Optional section of the README, and then move it to a new file if it gets too long. |
I think we may have a problem here with Django <1.10 and first-request logins. I like the idea of using a foreign key for the session mapping table. That way we don't have to care about cleaning up our table. But this comes with the drawbacks, that we rely on the usage of the db SessionStore (which is quite common) and that the session needs to be already persisted in the database when our middleware runs. |
The real work still needs to be done: * store mapping shib session -> django session on login * delete django user session on logout notifier call
In Django dashes in headers are replaced by underscores. We have to respect that. Otherwise we will get a KeyError (as I did at first in my test env). See https://stackoverflow.com/a/24355709/1381638
My code is based on the example code in the master branch. There ServiceBase was exchanged with Service. Let's support both variants.
Backchannel SLO introduces new dependencies and is perhaps not needed / wanted by everyone. Disable it by default.
If the user directly accesses the shibboleth login path (session_key is None) on Django version < 1.10, in auth.login the session will be persisted in the database and get deleted again immediately. This causes the insertion of the slo session mapping to fail (foreign key constraint). As a workaround we give him a session to delete.
44b89e7
to
509bd91
Compare
I could now reproduce the issue using Chromium webbrowser, when calling the shibboleth login endpoint of my webapp directly (before that I deleted all site cookies and disabled the embedded discovery service). |
shibboleth/middleware.py
Outdated
|
||
|
||
# store session mapping | ||
ShibSession.objects.get_or_create(shib=request.META['Shib_Session_ID'], session_id=request.session.session_key) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@egroeper can you make this DB call only happen if the SLO stuff is enabled in app_settings?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. It's really better to guard this as well.
ae146e6
to
9fc537a
Compare
9fc537a
to
a55614b
Compare
Please don't merge this, yet. I'm still investigating an issue when both front-channel and back-channel logout are in place. |
For back-channel SLO to work you need to configure service notification in the shibboleth sp. One possible solution would be to not do the user logout ( Here a new question arises: Do we want to support django project with additional authentication backends beside Shibboleth? |
Does this package currently work with other authentication backends? If not, seems like we wouldn't need to worry about it for this feature. |
Yes. I'm pretty sure, that it is currently possible to combine local (database) accounts, Shibboleth authentication and even other backends like LDAP. I will try to find a solution and you can review the patch and we discuss, if something and what should be changed. |
For our django project I implemented SLO support using back channel as an addition to this nice application.
Are you interested in including this in the upstream project or is this considered out of scope?
This introduces a dependency on spyne (and lxml) and needs an additional database table for mapping shibboleth sessions to django sessions (since we can't access the session of the user using the back channel).
Perhaps I could make back channel SLO and the dependencies belonging to it a configurable / optional feature?
I currently tested this on the test server of our service (using shibboleth-sp2 version 2.5.3 of Ubuntu 16.04), since I needed / wanted an IdP server to interact with.
Unfortunately there is no release of spyne, that is working with a recent Django, but with current master (b3bb2571d), it works fine.
This currently lacks tests and I'm not sure how / if that can be done.
Perhaps it is possible to simulate the IdP soap request by using the django.test.TestCase.client.
If you don't think this is generally out of scope, please review it and let's discuss what needs to be done to get this merged.