Authorization helpers¶
SecurityService gives the page model chain one place to ask who the current user is, whether the user is external, whether a caller-supplied role is held, and whether a policy may be viewed.
| Field | Value |
|---|---|
| Operation ID | OP-15 |
| Trigger | Calls from page models |
| Inputs | Role name, policy number, current HTTP identity |
| Outputs | Booleans, user id, ExternalUser |
| Primary components | SecurityService.GetCurrentUserId, IsUserExternal, IsAuthorizedAsync, GetCurrentExternalUserAsync, IsValidPolicyForCurrentUser |
| Entry point | src/BolMiddleware/Services/Security/SecurityService.cs |
Steps¶
GetCurrentUserIdreturns the authenticated identity name fromIHttpContextAccessor, or null.IsUserExternalcompares the domain portion of the identity name withSAIF(BR-BOLMIDDLEWARE-005).IsAuthorizedAsync(role)callsISecurityClient.IsAuthorizedfor the caller-supplied role; the library defines no role names.GetCurrentExternalUserAsynccallsISecurityClient.GetExternalUserfor the external user record.IsValidPolicyForCurrentUser(policyNumber)asks the Policy Core API whether the user may see the policy and returns the answer (BR-BOLMIDDLEWARE-009).
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
Start([Page model call]) --> D1{Which question?}
D1 -->|User id| S1[Read identity name]
D1 -->|External?| S2[Compare domain with SAIF]
D1 -->|Role| S3[ISecurityClient IsAuthorized]
D1 -->|External user| S4[ISecurityClient GetExternalUser]
D1 -->|Policy access| S5[IPolicyCoreApiClient IsValidPolicyForUser]
S1 --> EndOk([Return answer])
S2 --> EndOk
S3 --> EndOk
S4 --> EndOk
S5 --> EndOk
Failure and edge-case behavior¶
- The internal or external decision rests on the identity name text, not on a claim or role.
- Callers must pass role names; no default roles are defined in this library.
Related documentation¶
- Index
- Overview
- Architecture
- Dependencies
- Configuration
- Operations and processes
- Business rules
- Security and authorization
- Service registration
- API reference
Sources¶
- src/BolMiddleware/Services/Security/SecurityService.cs
- src/BolMiddleware/Services/Security/ISecurityService.cs
- src/BolMiddleware/Models/BolMenuModel.cs