crossbar.router.cookiestore¶
Classes¶
Cookie store common base. |
|
A persistent, database-backed cookie store. This implementation uses a zLMDB |
|
A persistent, file-backed cookie store. |
|
Memory-backed cookie store. |
Module Contents¶
- class CookieStore(config: Dict[str, Any])[source]¶
Bases:
objectCookie store common base.
- _connections: Dict[str, Set[autobahn.wamp.interfaces.ISession]][source]¶
- addProto(cbtid: str, proto: autobahn.wamp.interfaces.ISession) → int[source]¶
Add given WebSocket connection to the set of connections associated with the cookie having the given ID. Return the new count of connections associated with the cookie.
- dropProto(cbtid: str, proto: autobahn.wamp.interfaces.ISession)[source]¶
Remove given WebSocket connection from the set of connections associated with the cookie having the given ID. Return the new count of connections associated with the cookie.
- getProtos(cbtid: str) → List[autobahn.wamp.interfaces.ISession][source]¶
Get all WebSocket connections currently associated with the cookie.
- class CookieStoreDatabaseBacked(dbpath: str, config: Dict[str, Any])[source]¶
Bases:
CookieStoreA persistent, database-backed cookie store. This implementation uses a zLMDB based embedded database with Flatbuffers data serialization.
- create() → Tuple[str, str][source]¶
Create and store a new cookie (unauthenticated) in the database.
- Returns:
A pair with Cookie value (ID,
cbtid) and complete Cookie HTTP header value.
- delAuth(cbtid: str) → bool[source]¶
Delete an existing cookie (if any), including any authentication info and the cookie itself.
- Parameters:
cbtid – Cookie value (ID) of cookie to delete.
- Returns:
Flag indicating an existing cookie was deleted.
- exists(cbtid: str) → bool[source]¶
Check if a cookie with given value currently exists in the cookie store.
- Parameters:
cbtid – Cookie value (ID) to check.
- Returns:
Flag indicating whether a cookie (authenticated or not) is stored in the database.
- getAuth(cbtid: str) → Tuple[str | None, str | None, str | None, str | None, Dict[str, Any] | None][source]¶
Get the authentication info (if any) for a cookie stored in the database.
- Parameters:
cbtid – Cookie value (ID) to get authentication for.
- Returns:
A tuple
(authid, authrole, authmethod, authrealm, authextra)if the cookie exists, or a tuple(None, None, None, None, None)if no cookie with givencbtidis currently stored.
- setAuth(cbtid: str, authid: str | None, authrole: str | None, authmethod: str | None, authextra: Dict[str, Any] | None, authrealm: str | None) → bool[source]¶
Update the authentication information associated and stored for an existing cookie (if any).
- Parameters:
cbtid – Cookie value (ID) to update authentication for.
authid – The WAMP authid a cookie-authenticating session is to be assigned.
authrole – The WAMP authrole a cookie-authenticating session is to join under.
authmethod – The WAMP authentication method to be returned to the client performing this cookie-based authentication.
authextra – The WAMP authentication extra data to be returned to the client performing this cookie-based authentication.
authrealm – The WAMP realm a cookie-authenticating session is to join.
- Returns:
Flag indicating an existing cookie was modified.
- class CookieStoreFileBacked(cookie_file_name, config)[source]¶
Bases:
CookieStoreMemoryBackedA persistent, file-backed cookie store.
This cookie store is backed by a file, which is written to in append-only mode. Hence, the file is “growing forever”. Whenever information attached to a cookie is changed (such as a previously anonymous cookie is authenticated), a new cookie record is appended. When the store is booting, the file is sequentially scanned. The last record for a given cookie ID is remembered in memory.
- class CookieStoreMemoryBacked(config: Dict[str, Any])[source]¶
Bases:
CookieStoreMemory-backed cookie store.
- delAuth(cbtid: str) → bool[source]¶
Delete an existing cookie (if any), including any authentication info and the cookie itself.
- Parameters:
cbtid – Cookie value (ID) of cookie to delete.
- Returns:
Flag indicating an existing cookie was deleted.