Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Session management#1543

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
lullis wants to merge2 commits intodjango-oauth:master
base:master
Choose a base branch
Loading
frommushroomlabs:session_management

Conversation

@lullis
Copy link
Contributor

@lullislullis commentedJan 27, 2025
edited
Loading

Fixes#1130

Description of the Change

Implementation of OIDC Session Management. This PR:

  • Adds some settings variables to enable OIDC Session Management
  • Adds checks to validate OIDC Session Management settings - if it is enabled, then Django will require aOIDC_SESSION_MANAGEMENT_DEFAULT_KEY to be present.
  • Adds the session_state parameter to the parameters given to the end user client upon succcessful authorization. The session state is calculate by a salted hash combination of client id, origin and "OP user agent state", which for the intents of session management is itself just a hashed value of the session key for authenticated users, andOIDC_SESSION_MANAGEMENT_DEFAULT_KEY if the user is not authenticated. This is enough for the OP to indicate whether the end user session has changed (logged in, logged out)
  • Add a OIDCSessionManagementMiddleware that sets a cookie with the value of "OP user agent state"
  • Adds a SessionIFrameView endpoint for the "OP IFrame"

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name inAUTHORS

@lullislullisforce-pushed thesession_management branch 7 times, most recently from926e384 to27f2c7bCompareJanuary 29, 2025 23:22
@dopry
Copy link
Member

@lullis Thank you for working on this. I've only given it a cursory review, but it looks like a great start. It'll probably be late next week before I can look at this closely. Ping me again if I don't manage to get you a review by next Friday.

@lullislullisforce-pushed thesession_management branch 7 times, most recently fromec3ccd9 to3c3d1bfCompareApril 27, 2025 19:01
@lullislullis marked this pull request as ready for reviewApril 27, 2025 19:02
@django-oauthdjango-oauth deleted a comment fromcodecovbotApr 27, 2025
@Qup42
Copy link
Contributor

@lullis I'm quite busy at the moment. I think that I should be able to have a look at this in the next ~3 months. Do please remind me if I forget it.

@lullis
Copy link
ContributorAuthor

@Qup42, just pinging to remind you about this PR.

@dopry
Copy link
Member

@lullis any guidance on testing procedures for this PR?

@lullis
Copy link
ContributorAuthor

@dopry I got a small app going to test these features athttps://codeberg.org/raphael/oidc-client-testbed.

I won't make any strong claims about its overall quality (I relied on Cursor to generate a lot of the boilerplate and the vue components), but I did check the actual functionality and it works well enough to check the session frame part.

@dopry
Copy link
Member

@lullis I was wondering more about test plans I could follow for testing manually. I can try to use your OIDC test bed, we also have the test/app/rp which we can use, although it may need to be updated. Not sure if I have session handling in that client.

@lullis
Copy link
ContributorAuthor

@dopry, I am reasonably confident that there is nothing about session handling in that client - at least not related to the session iframe. If started my vue app precisely because I couldn't find any demo application that exercised this functionality.

Anyway, I was testing this with my app by running both the idp and the vue app. You can then login through the vue app, which will authenticate you in the idp. Once you login there will be a "session info" tab that will show you as logged in. You can open a console and you will see that the rp has an iframe which will be pinging the idp every few seconds. If you open another tab and logout directly on the IDP, the session will be finished and the rp will then show you as logged out.

@dopry
Copy link
Member

dopry commentedAug 13, 2025
edited
Loading

the RP uses my svelte-oidc package which is a proxy tohttps://github.com/DuendeArchive/identity-model-oidc-client-js more or less. I'm fairly certainhttps://github.com/DuendeArchive/identity-model-oidc-client-js/blob/dev/src/SessionMonitor.js handles session management in that library. Whether the tests/app/rp has session management enabled is another question.

I've been meaning to update that tohttps://github.com/authts/oidc-client-ts, which is a TS port of the same library.

lullis reacted with thumbs up emoji

Copy link
Member

@doprydopry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Looking good... just two items stand out to me at the moment upon a quick review.

If unset, the default location is used, eg if ``django-oauth-toolkit`` is
mounted at ``/o/``, it will be ``<server-address>/o/userinfo/``.

OIDC_SESSION_IFRAME_ENDPOINT
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Why allow an iframe endpoint setting? It seems like this could become a support headache. Couldn't someone just override the url view if they wanted?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Good question. To be honest I was just following the pattern established by the UserInfoView, which seems to do something similar?

…ion-1_0.html)To enable it, user must add OIDC_SESSION_MANAGEMENT_ENABLED and provideOIDC_SESSION_MANAGEMENT_DEFAULT_SESSION_KEY on OAUTH2_PROVIDER settings,and add the proper middleware.This PR contains: - change in AuthorizationView to return 'session_state' parameter in   authentication response - a SessionIFrameView as part of the OIDC views, which renders the content   of the iframe used by RPs to keep track of session state changes. - middleware that sets the cookie - Documentation - Test for the changed authentication view
@codecov
Copy link

codecovbot commentedAug 14, 2025
edited
Loading

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report?Let us know!

@dopry
Copy link
Member

Looks like we have at least 4 more code branches to test in order to get coverage where it needs to be.

@lullis
Copy link
ContributorAuthor

@dopry added missing tests, looks like codecov is happy now...

@hansegucker
Copy link

@dopry Would be great if we could get forward with this feature, too ;-)

@dopry
Copy link
Member

A way you can help streamline the review process for me is lay out an easy end to end tests for me using the tests/rp and tests/idp or some other setup using docker compose so I can verify the functionality more easily without needing to implement a client to test each of these features myself.

@lullis
Copy link
ContributorAuthor

lullis commentedNov 3, 2025
edited
Loading

or some other setup using docker compose

Can you please check ifhttps://codeberg.org/raphael/oidc-client-testbed would work for you? It does have a way to test the session iframe. I can make a docker image if you want, as well.

@dopry
Copy link
Member

dopry commentedNov 3, 2025
edited
Loading

I only have a few hours a week for work on this project... Having to spin up and configure a 3rd party example will eat up all my review time for a week. 3rd Party examples do not create an easy way for other developers to test the features in the future, nor does it provide example implementations for consumers. I'd really like to keep all the functionality demonstration in tests/app/[idp,rp]. That said I'll try to get your example setup to test... just don't expect any additional review by me this week.

Ultimately, I want all of this local so we can start working on setting up playwright tests that run through all the features so it's not something maintainers need to do manually with every change.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@doprydoprydopry requested changes

@charleswhchancharleswhchanAwaiting requested review from charleswhchan

@Qup42Qup42Awaiting requested review from Qup42

Requested changes must be addressed to merge this pull request.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

OpenID Connect Session Management 1.0

4 participants

@lullis@dopry@Qup42@hansegucker

[8]ページ先頭

©2009-2025 Movatter.jp