Identity, Authorization, and Least Privilege › Authorization as a function
Language AI HandbookAll chapters An authorization decision can be represented as a function from a trusted request context to a decision label:
The context includes the resolved resource, the proposed operation, trusted principal records, and the preserved authority state. The function chooses one label. Only Allow admits the request to the effect step, where the service must apply the same authorization conditions. The remaining outcomes explain what needs to happen before any further effect can be considered.
- Allow means all fixture conditions pass.
- Deny means at least one required condition failed, such as workspace, scope, or delegation membership.
- StepUp requests a separate human decision for an otherwise permitted effect.
- Expired means the supplied clock is at or beyond at least one grant's exclusive expiry.
- Revoked means at least one hop is already marked withdrawn in the supplied authority state.
The reason label is an engineering choice. This fixture gives revocation priority over expiry so one case with both conditions produces a predictable diagnostic. It does not recommend publishing detailed policy internals to the caller. Store safe internal reasons separately from an external result when details would expose protected policy or resource information.
We can illustrate these labels with a small matrix of named cases. The inputs are designed examples, so their counts describe the exercises only. They are not frequencies for live users or a measure of how well the control protects a deployment. The evaluator consumes the same context for the worked examples and for the outcome matrix later in this chapter. In the matrix each row identifies an operation and each column identifies one of its possible verdicts. Reporting counts preserves the distinction between expiration, explicit withdrawal, and a current request that requires a separate human decision. For a small toy suite the names of the individual cases remain more useful than percentages. In a live decision log, use a denominator that answers the operational question and keep policy changes visible when comparing different periods.
An expired request can be reconsidered only under fresh authority that still applies to the task. A revocation may reflect a canceled delegation or another authorized policy change. Automatic retries should respect the same authority and freshness conditions as the original attempt. A case requiring StepUp has to return through the policy gate after an independently recorded approval. The acceptance of a new context may change the outcome, while submitting the same unchanged context reproduces the same result.
A deny-by-default service needs an explicit answer when a required identity, scope, resource, or state is unknown. OWASP's authorization guidance recommends denying by default and checking permissions on each request. Some denial reasons are relevant to a service operator and others are safe to show to a user. Keep the observation needed to investigate a decision, along with the policy snapshot, without making the model the custodian of those records.
The example records the initiating principal, the acting workload, the operation enum, the resource identifier and its workspace, the consented scopes, the delegation chain, the decision clock, and an optional approval record. The resource key combines its workspace with its identifier. This makes two drafts with the same name in different workspaces distinct policy targets. The same namespace can contain multiple drafts, so a workspace match alone also provides insufficient information.
Least privilege means granting the authority necessary to complete the task. A narrow operation, resource set, and validity interval can all reduce delegated authority. An effect can require narrower controls than a read, even when both operations use the same workspace and resource identifier. In a more general policy, roles can establish common task permissions, while resource relationships and attributes qualify how those permissions apply.
The evaluator checks constraints in a fixed order so the displayed reason is reproducible. The order only controls the first failure we report. Each condition must still be checked before any Allow. The tests include cases with one failing condition and a case in which more than one validity rule applies.
Evaluation order
This fixture uses the following order.
- Require a delegated chain and nonempty identifiers on the trusted principal records. Require the user, workload, and resolved draft to be in the same workspace in this policy.
- Bind the first hop to the user and the last hop to the acting workload. Require a nonempty principal identity on each hop, the same workspace throughout, and a positive validity interval.
- Check current grant state. No revoked grant may authorize the operation. A grant applies in the half-open interval from its issue tick up to but excluding its expiry tick.
- Require adjacent hops to connect. Check that each child stays within its parent's resource set, scope set, and time interval. Check the request against trusted consent, the delegated scope, and the last hop.
- Apply an extra approval check for an otherwise permitted review action. The trusted approval refers to the particular user, workload, operation, resource, and validity interval.
The code checks revocation before expiry once the basic chain and identities are present. That choice gives an internal diagnosis when the context contains both states. It does not produce broader authority. The intended behavior is a conjunction of controls, so a grant satisfying scope still needs valid workspace, resource, time, chain and consent checks.
When a production service lacks trusted current facts, it can reject or defer the effect according to its policy. Logging the reason is useful for operators, but the type system and logs cannot substitute for a missing binding or an unavailable authority service.
Comments
Add to the conversation
A question, a correction, or an example from your own work.
No comments yet. Be the first to share your thoughts!