-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
feat(auth): Implement SSO session expiry #29422
Conversation
0f24b7c
to
c957b8d
Compare
c957b8d
to
1303839
Compare
1303839
to
3d44c00
Compare
3d44c00
to
6235173
Compare
src/sentry/utils/auth.py
Outdated
sso.append(str(organization_id)) | ||
request.session[SSO_SESSION_KEY] = ",".join(sso) | ||
key = sso_session_key_for_org_id(organization_id) | ||
request.session[key] = {"auth_timestamp": datetime.now(tz=timezone.utc).timestamp()} |
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.
could technically store it as a datetime object instead of the raw timestamp since this is pickled, but for size considerations think a raw float timestamp is better.
400556b
to
1732a9e
Compare
Aside one thing to remember about cookies is size matters. Its probably worth shrinking variable names in session keys/cookies as best as you can and defining constants to reference them. |
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.
lgtm!
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.
LGTM! Nicely factored, very easy to follow.
thanks for the reviews @RyanSkonnord @maxiuyuan. As I'm headed off for a 1.5 week vacation wednesday, i'm going to add "do not merge" and we can deploy when I get back. In the meantime will test on staging. |
#sync-getsentry
Problem
We'd like to have users reauthenticate with their SSO providers on a more frequent basis. Right now they simply expire with the django session timeout of two weeks. SSO sessions are stored in the django session as a list of comma-delimited org ids under the
sso
key.Solution
sso_s:org_id
. In the value of this, we'll store a dictionary (more on that later), with only one value currently, a utc timestamp of when the user last authenticated SSO.auth_timestamp
, and if this timestamp was further back than our expiry limit (20 hours), we'll return False which will force the user to re-authenticate for that organization.TODO:
Future use cases:
SessionNotOnOrAfter
Footnotes