Class UiAccessService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleancanRead(Principal principal, AccumulationRegisterDescriptor descriptor) booleancanRead(Principal principal, CatalogDescriptor descriptor) booleancanRead(Principal principal, DocumentDescriptor descriptor) booleancanRead(Principal principal, InformationRegisterDescriptor descriptor) booleanRead-access check against a pre-resolved role set, for callers that capture the subscriber's authorities up front and evaluate access off the request thread.booleancanReceiveEvent(Set<String> roles, String entityType, String entityName) Whether a live SSE event forentityType/entityNamemay be delivered to a subscriber holdingroles(#190).booleanWrite-access counterpart ofcanRead(Principal, String, String): resolves the entity by kind + name (route segment or display name, normalized the same way) and checks the caller against its effective write roles — write roles fall back to read roles when unset, the same rule the descriptor overloads apply.booleancanWrite(Principal principal, AccumulationRegisterDescriptor descriptor) booleancanWrite(Principal principal, CatalogDescriptor descriptor) booleancanWrite(Principal principal, DocumentDescriptor descriptor) booleanhasAnyRole(Principal principal, List<String> requiredRoles) Whether the caller holds any ofrequiredRoles(ADMINalways passes).voidrequireRead(Principal principal, AccumulationRegisterDescriptor descriptor) voidrequireRead(Principal principal, CatalogDescriptor descriptor) voidrequireRead(Principal principal, DocumentDescriptor descriptor) voidrequireRead(Principal principal, InformationRegisterDescriptor descriptor) voidrequireWrite(Principal principal, CatalogDescriptor descriptor) voidrequireWrite(Principal principal, DocumentDescriptor descriptor) The normalized roles granted to the caller.
-
Constructor Details
-
UiAccessService
-
-
Method Details
-
canRead
-
canWrite
-
canRead
-
canWrite
-
canRead
-
canWrite
-
canRead
-
requireRead
-
requireWrite
-
requireRead
-
requireWrite
-
requireRead
-
requireRead
-
canRead
-
canWrite
Write-access counterpart ofcanRead(Principal, String, String): resolves the entity by kind + name (route segment or display name, normalized the same way) and checks the caller against its effective write roles — write roles fall back to read roles when unset, the same rule the descriptor overloads apply. Used to stampcanWriteinto UI descriptors so the client can hide write affordances (row Edit/Delete, kanban drag, related-list add) that the REST layer would reject anyway. -
canRead
Read-access check against a pre-resolved role set, for callers that capture the subscriber's authorities up front and evaluate access off the request thread. The live SSE stream (UiEventPublisher) fans events from the event-publishing / cluster-relay thread, whereSecurityContextHolderno longer holds the subscriber's authentication — so thePrincipaloverloads (which resolve roles from the in-flight request) can't be used there. Capture roles withroles(Principal)at subscribe time, then gate each event with this.Semantics mirror
canRead(Principal, String, String)exactly: {name} arrives as the route segment (e.g. "properties"), not the descriptor's display name ("Properties"), so it is resolved the same case-/separator-insensitive way the generic controllers and query services do (seeCatalogQueryService) — otherwise a perfectly-readable entity is treated as unknown just because its display name isn't already lower-cased (#127). -
canReceiveEvent
Whether a live SSE event forentityType/entityNamemay be delivered to a subscriber holdingroles(#190). Modelled kinds (catalog/document/register) use the per-entity read grant. Acommentevent is scoped to the commented record — a catalog or document namedentityName(seeCommentController) — so it is authorized by that record's read grant. Any other event type is delivered only to theADMINsuperuser: fail closed, so a new event kind can't leak before this filter is taught to authorize it. (Thepresencesentinel is authorized by the publisher, which maps the record kind itself.) -
roles
The normalized roles granted to the caller. Authorities are read off the request'sAuthenticationreflectively, because this module deliberately does not depend on Spring Security — only its runtime presence.The
Principalthat Spring injects into a controller is not guaranteed to be the authority-bearingAuthentication: depending on the auth backend it can be a barePrincipal, aUserDetails/OidcUser, or otherwise expose no readablegetAuthorities(). When the injected principal yields nothing we fall back to the authenticated token held in theSecurityContext, which is the canonical source of authorities for the in-flight request. Without this fallback, write checks (the only callers ofrequireWrite) 403 even privileged users, includingADMIN. See issue #54. -
hasAnyRole
Whether the caller holds any ofrequiredRoles(ADMINalways passes). Same semantics as the per-entity checks; also the gate for an action's declaredActionSpec .roles(...)(#227). Note this stays deny-by-default: an emptyrequiredRolesmatches nobody but the superuser, so callers with an optional role list must skip the check when the list is unset rather than pass an empty one.
-