REST API#
The Permission Service exposes an HTTP/JSON API for checking authorization decisions. It provides two endpoints:
POST /v1beta/authorization/– checks whether a principal is allowed to perform a single action on a resource;POST /v1beta/authorization/batch/– checks whether a principal is allowed to perform several actions in one request.
Both endpoints return HTTP 200 for any request that is evaluated; the authorization outcome is carried in the response body, not in the status code. Failures that prevent evaluation are reported with the error status codes listed in Error codes, whose body is always a plain-text ErrorString message, not JSON.
The key words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL” in this section are to be interpreted as described in RFC 2119.
Authentication#
Callers SHOULD authenticate with the Authorization header in the Bearer <token> format. When authentication is enabled, the token MUST be a valid credential accepted by the service (by default a JWT issued by the Identity Provider for a user or a service). Requests with a missing, invalid, or expired token MUST be rejected with 401.
An implementation MAY support other authentication mechanisms (for example Basic Auth, API keys, or SAML2) and MAY change how authentication information is passed. When authentication is disabled, the service MAY process requests without credentials.
The underlying authorization system MAY allow a caller to check permissions for a principal different from the authenticated caller (for example an administrator checking another user). When this is not permitted, the service MUST reject the request with 403.
Error codes#
The following status codes report failures that prevent a request from being evaluated. The response body for every error is a plain-text ErrorString message with a text/plain content type. Clients MUST NOT parse error bodies as JSON; the status code identifies the failure.
HTTP status |
Condition |
|---|---|
|
The request body is not valid JSON, or the payload matches the request model but contains information that cannot be evaluated (for example a resource |
|
Authentication credentials are missing, invalid, or expired. |
|
The caller is not allowed to check authorization for the specified payload. |
|
The request body is larger than the maximum allowed size. An implementation MAY limit the body size and MUST answer |
|
The |
|
The JSON body does not match the request model (for example a missing required field, a value of the wrong type, or an unknown |
|
The client is rate limited and MUST slow down. The service MAY include a |
|
An unexpected server error occurred. |
|
The credentials cannot be verified right now, for example because the Identity Provider is unavailable. The credentials were not found invalid; the client MAY retry the request later. |
Request and response models#
Principal#
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Unique principal identifier (the |
|
object |
No |
Additional claims carried in the principal token. |
Action#
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Operation name. Max 255 characters; pattern |
|
string |
Yes |
Name of the service where the operation is performed. Max 255 characters; pattern |
Resource#
Field |
Type |
Required |
Description |
|---|---|---|---|
|
string |
Yes |
Unique resource identifier. Max 2048 characters; MUST NOT contain control characters, |
|
string |
Yes |
Resource classification used for policy evaluation. MUST be a namespaced type name: max 255 characters, pattern |
|
object |
No |
Additional resource information that MAY be used to evaluate the authorization policy. |
ErrorString#
The body of every error response is a human-readable plain-text message, sent with Content-Type: text/plain (for example text/plain; charset=utf-8). It is not JSON: the message is not enclosed in quotes and is not wrapped in an object, so clients MUST NOT parse it as JSON. Max 2048 characters; pattern ^[\x20-\x7E\r\n]+$. For example:
HTTP/1.1 401 Unauthorized
Content-Type: text/plain; charset=utf-8
The principal token is expired.