arxiv.users.auth.sessions.store module

Internal service API for the distributed session store.

Used to create, delete, and verify user and client session.

class arxiv.users.auth.sessions.store.SessionStore(host, port, db, secret, duration=7200, token=None, cluster=True)[source]

Bases: object

Manages a connection to Redis.

In fact, the StrictRedis instance is thread safe and connections are attached at the time a command is executed. This class simply provides a container for configuration.

create(authorizations, ip_address, remote_host, tracking_cookie='', user=None, client=None, session_id=None)[source]

Create a new session.

Parameters:
  • authorizations (domain.Authorizations) –
  • ip_address (str) –
  • remote_host (str) –
  • tracking_cookie (str) –
  • user (domain.User) –
  • client (domain.Client) –
Returns:

Return type:

Session

Return type:

Session

delete(cookie)[source]

Delete a session.

Parameters:cookie (str) –
Return type:None
delete_by_id(session_id)[source]

Delete a session in the key-value store by ID.

Parameters:session_id (str) –
Return type:None

Generate a cookie from a domain.Session.

Return type:str
load(cookie, decode=True)[source]

Load a session using a session cookie.

Return type:Session
load_by_id(session_id, decode=True)[source]

Get session data by session ID.

Return type:Union[Session, str]

Validate session data against a cookie.

Parameters:
  • session (Session) –
  • cookie (str) –
Raises:

InvalidToken – Raised if the data in the cookie does not match the session data.

Return type:

None

arxiv.users.auth.sessions.store.create(self, authorizations, ip_address, remote_host, tracking_cookie='', user=None, client=None, session_id=None)[source]

Create a new session.

Parameters:
  • authorizations (domain.Authorizations) –
  • ip_address (str) –
  • remote_host (str) –
  • tracking_cookie (str) –
  • user (domain.User) –
  • client (domain.Client) –
Returns:

Return type:

Session

Return type:

Session

arxiv.users.auth.sessions.store.current_session()[source]

Get/create SearchSession for this context.

Return type:SessionStore
arxiv.users.auth.sessions.store.delete(self, cookie)[source]

Delete a session.

Parameters:cookie (str) –
Return type:None
arxiv.users.auth.sessions.store.delete_by_id(self, session_id)[source]

Delete a session in the key-value store by ID.

Parameters:session_id (str) –
Return type:None

Generate a cookie from a domain.Session.

Return type:str
arxiv.users.auth.sessions.store.get_redis_session(app=None)[source]

Get a new session with the search index.

Return type:SessionStore
arxiv.users.auth.sessions.store.init_app(app=None)[source]

Set default configuration parameters for an application instance.

Return type:None
arxiv.users.auth.sessions.store.load(self, cookie, decode=True)[source]

Load a session using a session cookie.

Return type:Session
arxiv.users.auth.sessions.store.load_by_id(self, cookie, decode=True)[source]

Load a session using a session cookie.

Return type:Session