arxiv.users.legacy.cookies module

Provides functions for working with legacy session cookies.

arxiv.users.legacy.cookies.pack(session_id, user_id, ip, issued_at, capabilities)[source]

Generate a value for the classic session cookie.

Parameters:
  • session_id (str) – The session ID associated with the cookie.
  • user_id (str) – The user ID of the authenticated account.
  • ip (str) – Client IP address.
  • issued_at (datetime) – The UNIX time at which the session was initiated.
  • capabilities (str) – This is essentially a user privilege level.
Returns:

Signed session cookie value.

Return type:

str

Return type:

str

arxiv.users.legacy.cookies.unpack(cookie)[source]

Unpack the legacy session cookie.

Parameters:cookie (str) – The value of session cookie.
Returns:
  • str – The session ID associated with the cookie.
  • str – The user ID of the authenticated account.
  • str – The IP address of the client when the session was created.
  • datetime – The datetime when the session was created.
  • datetime – The datetime when the session expires.
  • str – Legacy user privilege level.
Raises:InvalidCookie – Raised if the cookie is detectably malformed or tampered with.
Return type:Tuple[str, str, str, datetime, str]