SSO and Access Control for Enterprise AI Apps
It is week 7 at Nimbus Assure, and the security questionnaire's last open rows are about identity. Do staff sign in with Nimbus accounts? Can a handler see what only a team lead should? Can you show who looked at which claim? The review page still has no login. This lesson covers SSO and access control for an AI app: how staff sign in, what each role may do, and how the AI keeps to it.
The office ID card: one login for many apps
As Authentication vs Authorization explained, authentication proves who you are and authorization decides what you may do. Single sign-on (SSO) means one login, at the company's identity provider, opens many apps. An identity provider (IdP) holds staff accounts and checks who is signing in, usually with a password plus MFA, a second kind of proof such as a phone code. Microsoft Entra ID and Okta are common IdPs; say Nimbus uses Entra ID (illustrative).
Security teams want SSO because MFA and password rules live in one place, a leaver is switched off once rather than app by app, and your app stores no passwords to leak. So don't build your own login: plug into theirs.
SSO in plain terms: SAML and OpenID Connect
Apps trust an IdP through one of two standards. In SAML 2.0 (Security Assertion Markup Language), the older one, the IdP sends a signed XML document, an assertion, saying who the user is. OpenID Connect (OIDC), built on OAuth 2.0, sends a signed ID token, a JSON Web Token (JWT): a compact set of facts about the user, which the standard calls claims (not insurance claims).
The flowchart follows Ravi, a claims handler, through OIDC's authorization code flow, the usual one for web apps:
The aha is step 6: the app trusts Ravi because the IdP's signature checks out, not because it saw a password. Signed in to email earlier? Step 3 usually asks nothing: that is the single sign-on.
Here is an Entra ID token's payload, decoded and trimmed, with illustrative values:
{
"iss": "https://login.microsoftonline.com/3f9a…/v2.0",
"aud": "6b1e…",
"sub": "AAAAAAAAAAAAAAAAAAAAAIkzqF…",
"exp": 1797325200,
"nonce": "a81c…",
"name": "Ravi",
"roles": ["Claims.Handler"]
}
iss is the issuer, aud the app the token was made for, exp its expiry in seconds since 1970, sub the user's fixed ID, and nonce a random value the app sent in step 2. Reject the token if the signature fails, the issuer, audience or nonce is unexpected, or it has expired; a maintained OIDC library does this. Identify users by sub, never by name, which can change.
To connect, Nimbus IT registers the assistant in its IdP and gives you a client ID and a client secret, kept in the secrets store (lesson 15). You give them the exact redirect URI, where the IdP may send users back. Your library reads the IdP's endpoints and signing keys from its OpenID configuration document. SAML swaps metadata files instead: each side's URLs and the signing certificate.
Roles and permissions inside the AI app
The IdP proves who Ravi is; your app decides what Ravi may do. Nimbus IT puts staff in groups, such as the home claims team, and assigns each group an app role, a role defined for your app alone, sent in the token's roles. Your app maps roles to permissions:
Claims.Handler: see the team's drafts and save them.Claims.TeamLead: the same, plus claims under fraud review.- No role: nothing. The app answers 403, even though sign-in worked.
Check the role on the server, on every request: a hidden button protects nothing. Joiners, movers and leavers are handled in Nimbus's IdP, so your app keeps no staff list.
Two catches. Roles are read from the token at sign-in, so a mover's new role arrives at their next sign-in. And unlike a cancelled card, disabling a leaver stops new sign-ins, not a session already open: Microsoft's docs say the app must end it. So keep sessions short, eight hours for example, or let the IdP deactivate users in your app through SCIM (System for Cross-domain Identity Management), the standard for an IdP to create and remove app accounts.
Making the AI respect the user's own access
The trap: the assistant reads through its service account (lesson 15), which sees every record on a policy, more than any one person may. If it answers from all of it, anyone who can ask can read it: the AI becomes a way around Nimbus's rules.
Each draft lists the earlier claims on its policy, to flag repeats (lesson 15). Nimbus's rule, illustrative: only team leads see that a claim is under fraud review. Watch where the filter sits when Ravi and Lin open the same claim:
The aha: the filter runs before the prompt. The model never saw CL-58312 in Ravi's request, so no mistake or injected instruction can reveal it. A prompt line such as "never mention fraud reviews to handlers" is not access control: the record would still be in the context.
In this sketch of the filter, fetch_earlier_claims and ask_model stand for your own functions, and session.roles holds the roles from sign-in:
SEES = { # Nimbus's rule, illustrative
"Claims.Handler": {"open", "closed"},
"Claims.TeamLead": {"open", "closed", "fraud_review"},
}
def visible(rows, roles):
allowed = set().union(*(SEES.get(r, set()) for r in roles))
return [row for row in rows if row["status"] in allowed]
rows = fetch_earlier_claims(policy) # service account: every record
answer = ask_model(question, visible(rows, session.roles))
An unknown role gets an empty set, so a mistake hides records rather than showing them. Actions follow the same rule: OWASP's Excessive Agency entry says to enforce authorization outside the LLM, so the save checks the user's role whatever the model suggests.
Where a source system can check the user itself, pass the user's identity on, so its owner's rules apply. And a draft made in the background, before anyone opens it, holds only what every role that may open it can see; role-dependent parts are fetched when a person opens the page, as that person.
Audit logs: who asked what
An audit log records who did what, and when, so that nobody can quietly change it. Lesson 13's log line helps engineers fix the system; the audit log answers security's questions, such as "who saw CL-58312?" Write one line per request, refusals included, with IDs, not claim text (illustrative, wrapped to fit):
{"time": "2026-12-15T10:42:07Z", "sub": "AAAAAAAAAAAAAAAAAAAAAIkzqF…",
"role": "Claims.Handler", "action": "earlier_claims", "claim": "CL-60417",
"shown": ["CL-55190"], "withheld": ["CL-58312"], "prompt": "v8",
"result": "allowed"}
Log sub, not a name, and the records the model was shown: those are what the user saw. A run of 403s can mean someone is probing. Free-text questions can hold personal data: agree with security whether to keep them.
Store entries append-only, added but never edited or deleted, and readable by Nimbus security alone. Add the audit log to lesson 16's retention table. Then test it: pick a claim and answer "who saw it, and when?" from the log alone.
Check yourself
Nimbus disables a leaver's account at 09:00, yet at 10:00 the leaver still opens the review page. How, and what closes the gap?
Disabling stops new sign-ins at the IdP, but the app's own session lasts until it expires. Short sessions, or SCIM telling the app to deactivate the account, close the gap.
A developer suggests adding "never mention fraud reviews to handlers" to the system prompt instead of filtering. Why isn't that enough?
The record is still in the model's context, so a mistake or an injected instruction can reveal it. Filtering before the prompt leaves nothing to reveal.
Security asks whether any handler was ever shown CL-58312. Which audit fields answer that?
shown and role: find entries with CL-58312 in shown and the role Claims.Handler. Logging the records shown, not answer text, turns this into a lookup.