---
title: ISecurityService
summary: API reference for ISecurityService.
status: draft
owner: SAIF IT Core Services
last_reviewed: 2026-10-12
library: BolMiddleware
reference_type: package
---

# ISecurityService

Contract for the user and access questions BOL pages ask: who the user is, whether they are external, whether they hold a role, and whether they may view a policy. `SecurityService` implements it.

## Purpose
- Isolate page models from the platform security client and the Policy Core API ([BR-BOLMIDDLEWARE-005](../../business-rules.md#br-bolmiddleware-005-external-user-detection), [BR-BOLMIDDLEWARE-009](../../business-rules.md#br-bolmiddleware-009-policy-access-validation)).

## Context
- Namespace: `BolMiddleware.Services.Security`
- Assembly/package: `BolMiddleware`

## Public members
| Member | Signature | Purpose |
| --- | --- | --- |
| `GetCurrentUserId` | `string? GetCurrentUserId()` | Returns the authenticated identity name. |
| `IsAuthorizedAsync` | `Task<bool> IsAuthorizedAsync(string role)` | Tells whether the current user holds the given role. |
| `IsUserExternal` | `bool IsUserExternal()` | True when the user is not on the internal SAIF domain. |
| `GetCurrentExternalUserAsync` | `Task<ExternalUser> GetCurrentExternalUserAsync()` | Fetches the external user record through `ISecurityClient.GetExternalUser`. |
| `IsValidPolicyForCurrentUser` | `Task<bool> IsValidPolicyForCurrentUser(long policyNumber)` | Tells whether the user may view the policy. |

## Behavioral notes
- Two callers block on the async members with `Task.Result`.

## Constraints and usage notes
- Registered as scoped.

## Sources
- src/BolMiddleware/Services/Security/ISecurityService.cs
