SecurityService¶
Implementation of ISecurityService. It reads the identity from the current HttpContext, delegates role checks and external user lookups to the platform ISecurityClient, and delegates policy access checks to the Policy Core API client (IPolicyCoreApiClient).
Purpose¶
- Derive the user id and the external flag from the identity name (BR-BOLMIDDLEWARE-005).
- Check policy access through the Policy Core API (BR-BOLMIDDLEWARE-009).
Context¶
- Namespace:
BolMiddleware.Services.Security - Assembly/package:
BolMiddleware
Public members¶
| Member | Signature | Purpose |
|---|---|---|
| Constructor | SecurityService(IHttpContextAccessor httpContextAccessor, ISecurityClient securityClient, other clients, IPolicyCoreApiClient policyCoreApiClient) |
Receives the accessor and clients. |
GetCurrentUserId |
string? GetCurrentUserId() |
Returns the identity name of the current user. |
IsAuthorizedAsync |
Task<bool> IsAuthorizedAsync(string role) |
Calls ISecurityClient to test the role. |
IsUserExternal |
bool IsUserExternal() |
Treats any identity outside the SAIF domain as external. |
GetCurrentExternalUserAsync |
Task<ExternalUser> GetCurrentExternalUserAsync() |
Looks up the external user through ISecurityClient.GetExternalUser. |
IsValidPolicyForCurrentUser |
Task<bool> IsValidPolicyForCurrentUser(long policyNumber) |
Asks the Policy Core API (IPolicyCoreApiClient.IsValidPolicyForUser) whether the user may view the policy. |
Behavioral notes¶
- Protected fields
_httpContextAccessor,_policyCoreApiClient, and_securityClientare available to subclasses.
Constraints and usage notes¶
- Depends on
ISecurityClient, which this library does not register.
Sources¶
- src/BolMiddleware/Services/Security/SecurityService.cs