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

Ability to track and revoke sessions #20378

Closed
8 tasks done
Fryguy opened this issue Jul 21, 2020 · 6 comments
Closed
8 tasks done

Ability to track and revoke sessions #20378

Fryguy opened this issue Jul 21, 2020 · 6 comments
Assignees
Milestone

Comments

@Fryguy
Copy link
Member

Fryguy commented Jul 21, 2020

As an admin, I'd like an endpoint to be able to revoke all sessions for a particular user
As an user, I'd like an endpoint to be able to revoke all of my sessions
As an admin or user, I'd like to specify one or more or all types of sessions when I make the revoke call


Observations

The UI maintains its session via a Rack session. The way this works is that when a user makes a request, Rack will assign that request a session id, and the response will include that session id as a cookie. Then subsequent requests are made with that cookie, and the session is continued for that user. Since sessions are distributed by Rack, these are not done in a user context, and therefore sessions are not directly associated with a user.

The backing store for a session is based on the Settings.server.session_store value and interpreted in an initializer here. In all cases, we use the underlying Rails session stores.

  • :active_record_store ultimately ends up using the Session model
  • :memory_store is in-memory
  • :mem_cache_store ultimately uses Rack::Session::Dalli from the dalli gem.

The API maintains tokens in a bespoke manner. The TokenManager is used for token generation, and generated values are stored in the TokenStore. The TokenStore looks at Settings.server.session_store, but doesn't use the same Rack session code, instead of doing it itself.


Proposal

@abellotti abellotti removed their assignment Jul 31, 2020
@chessbyte chessbyte added this to the Kasparov milestone Aug 4, 2020
@kbrock
Copy link
Member

kbrock commented Aug 4, 2020

Idea for item 4

Is it possible to have a single memcachd instance for multiple instances like we do for the database? This is the original intent of memcached

@himdel Do we store have too much data in the session for a single (remote) database to work?

@himdel
Copy link
Contributor

himdel commented Aug 4, 2020

Do we store have too much data in the session for a single (remote) database to work?

The old forms do still use the session for all the form data. It should not longer store any instances, but a list of all eligible somethings.id+label to populate a selectpicker would still be stored in the session.

So, yeah, I think it should work (but it may not be much faster than sql for data-heavy forms, until those get converted).

@himdel
Copy link
Contributor

himdel commented Aug 4, 2020

For the API, remove a majority of the custom TokenManager / TokenStore implementation and use the Rails conventions to treat a session like a token, leveraging Rack sessions.

So, SUI would use cookies?
Does this mean relying on ui-classic to log in, or making SUI into a rails engine to have a server part to get the cookie and csrf from? Or will the API implement a login screen?

@Fryguy
Copy link
Member Author

Fryguy commented Aug 4, 2020

While the rack session defaults to cookies, I think we may be able to change it to use any header (a cookie is just a header after all). If it's a response header then it's really no different than any other token returned in the header.

Or, yeah, maybe SUI should just use cookies...might be a lot easier and consistent?

@himdel
Copy link
Contributor

himdel commented Aug 4, 2020

I think we may be able to change it to use any header (a cookie is just a header after all).

Ah, good point, cool :)

Or, yeah, maybe SUI should just use cookies...might be a lot easier and consistent?

Maybe, I'm not opposed to it, but a login cookie should be http(s)-only, which means we need to be able to do a login action that results in the server returning the cookie and either html, or a redirect to a html endpoint (not json).

So we would need to reuse the ui-classic login screen, or add one to the API.

@Fryguy
Copy link
Member Author

Fryguy commented Oct 20, 2020

Done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Kasparov
Development

No branches or pull requests

9 participants