Class CookieJar
- Namespace
- Kuestenlogik.Bowire.Auth
- Assembly
- Kuestenlogik.Bowire.dll
The cookie jars (#681): one per workspace and environment, persisted in the workspace, applied to every protocol that goes over HTTP.
public static class CookieJar
- Inheritance
-
CookieJar
- Inherited Members
Remarks
A call opts in by carrying the environment id under MarkerKey
(the workbench does so when the environment's auth has "persist cookies"
on). The jar is BowireCookieJar: a CookieContainer
for the matching — domain, path, Secure and expiry follow RFC 6265 —
plus what the container does not keep (SameSite) and a file.
Persistent cookies are written to cookies.json in the workspace
(or the user's Bowire directory when no workspace is in scope, as in the
CLI) and survive a restart. Session cookies stay in memory and end with
the process, as a browser's do.
Fields
MarkerKey
The metadata key carrying the environment id whose jar a call uses.
public const string MarkerKey = "__bowireCookieEnv__"
Field Value
OptionKey
Where Attach(HttpRequestMessage, IEnumerable<KeyValuePair<string, string>>?) leaves the jar on a request.
public static readonly HttpRequestOptionsKey<BowireCookieJar> OptionKey
Field Value
Methods
Attach(HttpRequestMessage, IEnumerable<KeyValuePair<string, string>>?)
Carry the call's jar, if it asks for one, on request.
public static void Attach(HttpRequestMessage request, IEnumerable<KeyValuePair<string, string>>? metadata)
Parameters
requestHttpRequestMessagemetadataIEnumerable<KeyValuePair<string, string>>
Clear(string)
Forget every cookie of envId, in memory and on disk.
public static bool Clear(string envId)
Parameters
envIdstring
Returns
EnvIdOf(IEnumerable<KeyValuePair<string, string>>?)
The environment id in metadata, or null.
public static string? EnvIdOf(IEnumerable<KeyValuePair<string, string>>? metadata)
Parameters
metadataIEnumerable<KeyValuePair<string, string>>
Returns
ExportJson()
The current workspace's persisted jars as JSON ({ envId: [cookies] }),
for the workspace export. Session cookies are not in it; they end with the process.
public static string ExportJson()
Returns
For(string)
The jar for envId in the current workspace.
public static BowireCookieJar For(string envId)
Parameters
envIdstring
Returns
GetOrCreate(string)
The container for envId; kept for callers that only need matching.
public static CookieContainer GetOrCreate(string envId)
Parameters
envIdstring
Returns
ImportJson(string)
Replace the current workspace's persisted jars with environmentsJson
(the shape ExportJson() writes), for the workspace import.
The jars held in memory for this workspace are dropped and reload.
public static int ImportJson(string environmentsJson)
Parameters
environmentsJsonstring
Returns
Snapshot(string)
The cookies of envId that are still valid.
public static IReadOnlyList<CookieSnapshot> Snapshot(string envId)
Parameters
envIdstring
Returns
StoredEnvironments()
Every environment with a stored jar in the current workspace (for the CLI and MCP).
public static IReadOnlyList<string> StoredEnvironments()