ZoneSecurityContextHolderStrategy class final

The default strategy: each runWithContext scope has its own context, and code outside every scope shares one program-wide context.

A Dart server handles many requests at once on one thread, switching between them at each await, so "the current user" cannot be a global variable. A Zone follows the work of one request across its awaits, timers and streams; this strategy stores the context in it. The security filter chain runs every request in its own scope, so a request sees only its user.

Outside every scope there is one context for the whole program: what a Flutter app wants for its logged-in user, and what a server's own background work (not a request) sees.

Spring (Java): ThreadLocalSecurityContextHolderStrategy inside a scope (a Zone plays the role of the thread), and MODE_GLOBAL outside.

Implemented types

Constructors

ZoneSecurityContextHolderStrategy()
A strategy whose program-wide context starts empty.

Properties

hashCode → int
The hash code for this object.
no setterinherited
isScoped → bool
Whether the caller runs inside a runWithContext scope of this strategy; false means it uses the program-wide context.
no setter
onProgramWideAuthentication ↔ void Function(Authentication authentication, StackTrace where)?
Told each time an authentication is put into the program-wide context (set outside every scope), with where it was set; nothing is told by default.
getter/setter pair
programWideAuthentication → Authentication?
The authentication of the program-wide context: who all the code outside a scope acts as; null when nobody.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

clearContext() → void
Removes the current context; the next getContext creates an empty one.
override
createEmptyContext() → SecurityContext
A new context with no user, not yet stored anywhere.
override
getContext() → SecurityContext
The current context; an empty one is created and stored when there is none, so the result is never null.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
runWithContext<R>(R body(), [SecurityContext? context]) → R
Runs body with its own context (an empty one when omitted) and returns what body returns.
override
setContext(SecurityContext context) → void
Makes context the current one, in the current scope only.
override
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited