Repository navigation
v26.6.32
Spring Security parity — Tier 3: method-security depth. Expression-based
method security and domain-object permissions, the SpEL-equivalent layer over
the existing #[pre_authorize] / #[post_authorize] macros. All additive (no
behaviour change to existing code). Adversarially reviewed before release.
Added
- Expression-based
#[pre_authorize]— a non-keyword argument is now a
boolean Rust expression evaluated before the body with the method's
parameters andauth(a&Authentication) in scope (Spring's
@PreAuthorize("#id == authentication.name")), e.g.
#[pre_authorize(auth.has_role("ADMIN") || auth.principal == owner)]. The
keyword rules (authenticated,role,any_role,authority,
any_authority) are unchanged and fully backward-compatible. Fail-closed: no
ambient context denies withUnauthenticated, a false expression with
Forbidden. PermissionEvaluator+has_permission— the Rust analog of Spring's
PermissionEvaluator/hasPermission(target, permission). Register one
process-wide withset_permission_evaluator; call
has_permission(auth, target, permission)inside any pre/post expression. The
target is erased toAnyso one evaluator serves every domain type by
downcasting. Secure default: with no evaluator registered, every permission
is denied.#[pre_filter]/#[post_filter]— collection filtering (Spring's
@PreFilter/@PostFilter).#[post_filter(element.owner == auth.principal)]
retains only the elements of the returned collection the predicate accepts;
#[pre_filter(items, …)]filters a named ownedmutcollection argument
before the body.elementis the per-element&T(Spring'sfilterObject);
no ambient context denies the call withUnauthenticated.
Known limitations (roadmap)
PermissionEvaluatoris a process-global set-once registry (one evaluator per
process, like Spring's single bean); there is no per-scope override.#[pre_filter]requires the targeted parameter to be an ownedmut
collection withretain(e.g.mut items: Vec<T>).