--- name: security-identity description: Review and harden application authentication, authorization, OAuth, SSO, session lifecycle, account recovery, and multi-tenant isolation in source code. --- # Identity and tenant isolation Read the installed sibling `../web-security-audit/SKILL.md` for boundaries, evidence, and stopping rules. Apply this specialist workflow to the requested scope. For repository-specific context, use the template at `../web-security-audit/assets/context.md`. Reconcile existing context with current code and continue with available repository evidence if no context exists. Build a principal × action × resource × tenant matrix for critical operations. Include anonymous, ordinary user, tenant admin, support, integration, and service principals where present. Enumerate create, read, list, update, delete, export, and asynchronous continuations. Mark whether a decision depends on authentication state, role, resource ownership, tenant membership, or delegation. Trace identity from issuing authority through middleware into effective policy and the terminal database predicate or object operation. Compare default and administrative routes, bulk operations, and caches. A role check and tenant restriction enforce separate invariants. Record which layer binds the tenant and which identifier source it trusts. For row policies, inspect effective service roles, connection pooling, and transaction scope. Trace sign-in, account linking, refresh, recovery, revocation, and removal of roles or tenant membership. Check issuer/audience, key selection, scope, redirect registration, state, nonce, and PKCE where applicable. Compare token and session invalidation across browser, API, and background continuations. Where supported, trace passkey enrollment and recovery, federated account linking, provisioning and deprovisioning, service identities, and just-in-time administrative access. Check that security-sensitive changes require the appropriate fresh authorization and produce an attributable audit event. Review whether membership or role revocation propagates to caches, API keys, sessions and pending jobs within the intended window. For approved patches, test the normal allowed operation, denied policy decisions for synthetic principals, and absence of protected store writes on denial. Record the effective query restriction and compatibility implications for service and support roles. ## Authorization decision matrix Record principal, action, resource owner and tenant, expected decision, effective enforcement, and evidence. Include one permitted row and the nearest denial case for each critical policy. For delegated or revoked access, include the issuing authority, propagation boundary, and the component that finally enforces the decision. Return revision-relative evidence and coverage gaps using the report template at `../web-security-audit/assets/report.md`. Review lifecycle transitions that can leave stale authority. For permission removal, map the expected propagation window across sessions, issued credentials, caches and worker queues, and capture separate source and runtime evidence for each enforcement point. Read [the enterprise review guide](references/enterprise-review.md) when the system uses federation, delegated access, lifecycle provisioning, or multiple token audiences.