# Access and approvals

Tokens, access policy, dual-control approvals, break-glass and OpenID Connect sign-in. Aegis Core API, `AccessService`: 17 operations, generated from the OpenAPI document of Aegis Core 0.13.0.

## Logout

`POST /v1/auth/logout`

Ends the caller's own sign-in session.

- Role: `emergency` or higher
- gRPC: `/aegis.v1.AccessService/Logout`

Response `200` (`application/json`): [LogoutResponse](#schema-logoutresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Auth methods

`GET /v1/auth/methods`

The ways to sign in this daemon offers. Open to anyone.

- Role: none (open to anyone)
- gRPC: `/aegis.v1.AccessService/AuthMethods`

Response `200` (`application/json`): [AuthMethodsResponse](#schema-authmethodsresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## OIDC callback

`POST /v1/auth/oidc/callback`

Finishes an OpenID Connect sign-in: the code exchanged, the ID token checked, a session started. Open to anyone.

- Role: none (open to anyone)
- gRPC: `/aegis.v1.AccessService/OidcCallback`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `code` | string | The authorisation code. |
| `code_verifier` | string | The PKCE verifier whose S256 challenge the start was given (43 to 128 unreserved characters). |
| `state` | string | The state from the start. |
| `tenant` | string, nullable | The tenant to sign in to, when the identity has roles in several. |

Response `200` (`application/json`): [OidcCallbackResponse](#schema-oidccallbackresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## OIDC start

`POST /v1/auth/oidc/start`

Starts an OpenID Connect sign-in: the provider's authorisation URL, with a fresh state, nonce and PKCE challenge. Open to anyone.

- Role: none (open to anyone)
- gRPC: `/aegis.v1.AccessService/OidcStart`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `code_challenge` | string | BASE64URL(SHA-256(verifier)), 43 characters (RFC 7636, section 4.2). |
| `code_challenge_method` | string, nullable | `S256`, the only method accepted; absent means `S256`. |

Response `200` (`application/json`): [OidcStartResponse](#schema-oidcstartresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Get access policy

`GET /v1/sys/access/policy`

The access policy of the caller's tenant, what is in force for it, and the operations a policy can name.

- Role: `auditor` or higher
- gRPC: `/aegis.v1.AccessService/GetAccessPolicy`

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `tenant` | query | string, nullable | For a cross-tenant caller: whose policy; the default tenant's when absent. |

Response `200` (`application/json`): [AccessPolicyView](#schema-accesspolicyview)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Replace access policy

`POST /v1/sys/access/policy`

Replaces the access policy of the caller's tenant, whole; under dual control by default.

- Role: `admin` or higher
- gRPC: `/aegis.v1.AccessService/ReplaceAccessPolicy`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `policy` | [AccessPolicy](#schema-accesspolicy), nullable | The new policy, whole. An empty policy removes the tenant's. |
| `tenant` | string, nullable | For a cross-tenant caller: whose policy; the default tenant's when absent. |

Response `200` (`application/json`): [ReplaceAccessPolicyResponse](#schema-replaceaccesspolicyresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## List approvals

`GET /v1/sys/approvals`

The requests under dual control the caller's tenant can see, newest first.

- Role: `auditor` or higher
- gRPC: `/aegis.v1.AccessService/ListApprovals`

Response `200` (`application/json`): [ListApprovalsResponse](#schema-listapprovalsresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Get approval

`GET /v1/sys/approvals/{id}`

One request under dual control.

- Role: `auditor` or higher
- gRPC: `/aegis.v1.AccessService/GetApproval`

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `id` | path | string, required |  |

Response `200` (`application/json`): [Approval](#schema-approval)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Approve

`POST /v1/sys/approvals/{id}/approve`

Approves a pending request, as a principal independent of the requester.

- Role: `admin` or higher
- gRPC: `/aegis.v1.AccessService/Approve`

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `id` | path | string, required |  |

Request body, required (`application/json`):

No fields.

Response `200` (`application/json`): [Approval](#schema-approval)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Cancel approval

`POST /v1/sys/approvals/{id}/cancel`

Withdraws one's own request while it is open.

- Role: `admin` or higher
- gRPC: `/aegis.v1.AccessService/CancelApproval`

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `id` | path | string, required |  |

Request body, required (`application/json`):

No fields.

Response `200` (`application/json`): [Approval](#schema-approval)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Deny approval

`POST /v1/sys/approvals/{id}/deny`

Denies a pending request.

- Role: `admin` or higher
- gRPC: `/aegis.v1.AccessService/DenyApproval`

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `id` | path | string, required |  |

Request body, required (`application/json`):

No fields.

Response `200` (`application/json`): [Approval](#schema-approval)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## List break glass

`GET /v1/sys/break-glass`

The break-glass sessions running in the caller's tenant, and the longest one allowed.

- Role: `auditor` or higher
- gRPC: `/aegis.v1.AccessService/ListBreakGlass`

Response `200` (`application/json`): [ListBreakGlassResponse](#schema-listbreakglassresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Start break glass

`POST /v1/sys/break-glass`

Starts a break-glass session for a holder of the `emergency` role, with a reason.

- Role: `emergency` or higher
- gRPC: `/aegis.v1.AccessService/StartBreakGlass`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `reason` | string | Why, one line of 8 to 300 characters. |
| `seconds` | integer (int64) | How long, in seconds: 60 up to the policy's limit. |

Response `200` (`application/json`): [BreakGlassSession](#schema-breakglasssession)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## End break glass

`POST /v1/sys/break-glass/end`

Ends a break-glass session: the caller's own, or another's in the tenant by an administrator.

- Role: `emergency` or higher
- gRPC: `/aegis.v1.AccessService/EndBreakGlass`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `holder` | string, nullable | Whose session, for an administrator ending another's; the caller's own when absent. |

Response `200` (`application/json`): [EndBreakGlassResponse](#schema-endbreakglassresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## List tokens

`GET /v1/sys/tokens`

Every holder of the caller's tenant with their role, scope and where the token came from. Never a token or a hash.

- Role: `admin` or higher
- gRPC: `/aegis.v1.AccessService/ListTokens`

Response `200` (`application/json`): [ListTokensResponse](#schema-listtokensresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Issue token

`POST /v1/sys/tokens`

Issues a token, shown once: optionally scoped, expiring, bound to a client key, or in another tenant (the system's administrators only).

- Role: `admin` or higher
- gRPC: `/aegis.v1.AccessService/IssueToken`

Request body, required (`application/json`):

| Field | Type | Description |
| --- | --- | --- |
| `bound` | string, nullable | The SHA-256 of a client certificate's public key (64 hex digits): the token then works only over mutual TLS with that key. |
| `expires_in` | integer (int64), nullable | Seconds from now until it stops working: 60 to a year. Without it, it does not expire. |
| `name` | string | The holder's name. |
| `role` | string | `emergency`, `monitor`, `auditor`, `operator`, `admin` or a custom role. |
| `scope` | [TokenScope](#schema-tokenscope), nullable | What the token may reach. |
| `tenant` | string, nullable | The holder's tenant (`*` for the cross-tenant role); the caller's own by default. |

Response `201` (`application/json`): [IssueTokenResponse](#schema-issuetokenresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Revoke token

`POST /v1/sys/tokens/{name}/revoke`

Revokes a holder's token and retires the name for good.

- Role: `admin` or higher
- gRPC: `/aegis.v1.AccessService/RevokeToken`

| Parameter | In | Type | Description |
| --- | --- | --- | --- |
| `name` | path | string, required |  |

Request body, required (`application/json`):

No fields.

Response `200` (`application/json`): [RevokeTokenResponse](#schema-revoketokenresponse)

Errors: `400` · `401` · `403` · `404` · `409` · `413` · `500` · `503` ([what each means](https://docs.qblackbit.com/api/core/index.md#errors)).

## Schemas

### AccessPolicy

One tenant's access policy. What is left out takes the built-in value.

| Field | Type | Description |
| --- | --- | --- |
| `break_glass` | [BreakGlassLimits](#schema-breakglasslimits), nullable | Break-glass limits (system policy only). |
| `certificates` | array of [CertificateMapping](#schema-certificatemapping) | Client certificates accepted as principals (system policy only). |
| `dual_control` | [DualControl](#schema-dualcontrol), nullable | Dual control; for a tenant other than the default one, at least the system's. |
| `oidc` | array of [ClaimMapping](#schema-claimmapping) | OpenID Connect claims mapped to roles (system policy only). |
| `roles` | array of [CustomRole](#schema-customrole) | Custom roles. |
| `set_at` | integer (int64), nullable | When the policy was last replaced, set by the daemon, in seconds since the Unix epoch. |

### AccessPolicyView

A tenant's access policy and what is in force for it.

| Field | Type | Description |
| --- | --- | --- |
| `in_force` | [AccessInForce](#schema-accessinforce), nullable | What is in force for the tenant. |
| `operations` | array of [AccessOperation](#schema-accessoperation) | Every operation a policy can name. |
| `policy` | [AccessPolicy](#schema-accesspolicy), nullable | The policy as stored; empty when the tenant has none. |
| `tenant` | string | The tenant. |
| `writable` | boolean | Whether runtime changes can be kept. |

### Approval

A request under dual control. Approvers see the request's digest, never its body.

| Field | Type | Description |
| --- | --- | --- |
| `approvals` | array of [ApprovalVote](#schema-approvalvote) | Approvals given. |
| `created` | integer (int64) | When it was asked, in seconds since the Unix epoch. |
| `decided_by` | string, nullable | Who denied or withdrew it, when decided so. |
| `expires` | integer (int64) | When it stops waiting. |
| `id` | string | Its identifier. |
| `method` | string | The method. |
| `needed` | integer (int64) | Approvals needed. |
| `operation` | string | The operation. |
| `path` | string | The path with its query. |
| `request_sha256` | string | The SHA-256 of the method, path, tenants and body, in hexadecimal. |
| `requester` | string | Who asked. |
| `status` | string | `pending`, `approved`, `denied`, `cancelled`, `expired` or `used`. |
| `target` | string | The tenant the request acts on. |
| `tenant` | string | The requester's tenant. |

### AuthMethodsResponse

The ways to sign in.

| Field | Type | Description |
| --- | --- | --- |
| `oidc` | [OidcMethod](#schema-oidcmethod), nullable | OpenID Connect, when configured. |
| `token` | boolean | Bearer tokens: always. |

### BreakGlassSession

A break-glass session.

| Field | Type | Description |
| --- | --- | --- |
| `holder` | string | The holder of the `emergency` role. |
| `reason` | string | Why, one line. |
| `started` | integer (int64) | When it started, in seconds since the Unix epoch. |
| `tenant` | string | Its tenant. |
| `until` | integer (int64) | When it ends. |

### EndBreakGlassResponse

The session ended.

| Field | Type | Description |
| --- | --- | --- |
| `ended` | boolean | Always true. |
| `holder` | string | Whose it was. |

### IssueTokenResponse

The token, shown once.

| Field | Type | Description |
| --- | --- | --- |
| `expires` | integer (int64), nullable | When it stops working, in seconds since the Unix epoch. |
| `name` | string | The holder's name. |
| `role` | string | The role. |
| `tenant` | string | The holder's tenant. |
| `token` | string | The token. |

### ListApprovalsResponse

The requests under dual control.

| Field | Type | Description |
| --- | --- | --- |
| `approvals` | array of [Approval](#schema-approval) | Newest first. |
| `policy` | [DualControl](#schema-dualcontrol), nullable | Dual control in force for the caller's tenant. |

### ListBreakGlassResponse

The break-glass sessions running.

| Field | Type | Description |
| --- | --- | --- |
| `limit` | integer (int64) | The longest session the system's policy allows, in seconds. |
| `sessions` | array of [BreakGlassSession](#schema-breakglasssession) | The sessions the caller's tenant can see. |

### ListTokensResponse

The holders.

| Field | Type | Description |
| --- | --- | --- |
| `holders` | array of [Holder](#schema-holder) | Every holder the caller may see. |
| `retired` | array of string | Names never issued again. |
| `writable` | boolean | Whether runtime changes can be kept. |

### LogoutResponse

Whether a session ended.

| Field | Type | Description |
| --- | --- | --- |
| `signed_out` | boolean | Whether the caller's session was found and ended. |

### OidcCallbackResponse

The session.

| Field | Type | Description |
| --- | --- | --- |
| `display_name` | string, nullable | The configured name claim, for display only; absent when it cannot be trusted to name anyone. |
| `expires` | integer (int64) | When the session ends, in seconds since the Unix epoch. |
| `name` | string | The holder: `oidc.` and a digest of the issuer and `sub`, the same for one person always. |
| `role` | string | The role. |
| `tenant` | string | The tenant. |
| `token` | string | The session token (`ags_` and 64 hex digits), shown once. |

### OidcStartResponse

Where to send the browser.

| Field | Type | Description |
| --- | --- | --- |
| `authorization_url` | string | The provider's authorisation URL. |
| `expires` | integer (int64) | When the sign-in stops waiting, in seconds since the Unix epoch. |
| `state` | string | The state to send back with the code. |

### ReplaceAccessPolicyResponse

The policy now in force.

| Field | Type | Description |
| --- | --- | --- |
| `policy` | [AccessPolicy](#schema-accesspolicy), nullable | The policy as stored. |
| `tenant` | string | The tenant. |

### RevokeTokenResponse

The revocation.

| Field | Type | Description |
| --- | --- | --- |
| `name` | string | The holder. |
| `recorded` | string | `now`, or `at the next unseal` while sealed. |
| `revoked` | boolean | Always true. |

### TokenScope

What a scoped token may reach: each list, when given, narrows it.

| Field | Type | Description |
| --- | --- | --- |
| `keys` | array of string | Key names as the holder writes them, for example `payments-*`. |
| `operations` | array of string | Operations, for example `key.sign` or `key.*`. |
| `paths` | array of string | Route patterns, for example `/v1/keys/payments-*/sign` (`*` within a segment, `**` below). |

### BreakGlassLimits

How long a break-glass session may last.

| Field | Type | Description |
| --- | --- | --- |
| `max_seconds` | integer (int64) | Seconds, at most four hours. |

### CertificateMapping

A client certificate accepted as a principal.

| Field | Type | Description |
| --- | --- | --- |
| `name` | string | The principal's name in the audit chain. |
| `role` | string | Its role. |
| `spki_sha256` | string, nullable | The SHA-256 of its public key, lowercase hex: when given, only that key is accepted. |
| `subject` | string | The certificate's subject common name. |
| `tenant` | string | Its tenant, or `*`. |

### ClaimMapping

An OpenID Connect claim value that grants a role.

| Field | Type | Description |
| --- | --- | --- |
| `claim` | string | The claim, such as `groups` or `email`. |
| `role` | string | The role it grants. |
| `tenant` | string | The tenant it grants it in, or `*`. |
| `value` | string | The value it must hold. |

### CustomRole

A role the policy defines: a built-in base, narrowed by grants.

| Field | Type | Description |
| --- | --- | --- |
| `allow` | array of [AccessGrant](#schema-accessgrant) | What it may do: a request must match one grant. |
| `base` | string | `auditor`, `operator` or `admin`: the most the role can ever do. |
| `name` | string | Its name. |

### DualControl

M-of-N approval of the operations listed.

| Field | Type | Description |
| --- | --- | --- |
| `approvals` | integer (int64) | Approvals needed from principals other than the requester; 0 turns dual control off. |
| `operations` | array of string | The operations covered. |
| `window` | integer (int64) | Seconds a request waits for its approvals, and an approved request for its use. |

### AccessInForce

What is in force for a tenant.

| Field | Type | Description |
| --- | --- | --- |
| `break_glass_max` | integer (int64) | The longest break-glass session, in seconds. |
| `dual_control` | [DualControl](#schema-dualcontrol), nullable | Dual control: the stricter of the system's and the tenant's. |

### AccessOperation

One row of the authorisation matrix.

| Field | Type | Description |
| --- | --- | --- |
| `class` | string | `read`, `use`, `manage`, `audit`, `access` or `system`. |
| `method` | string | `GET` or `POST`. |
| `operation` | string | The operation, such as `key.sign`. |
| `path` | string | The route. |
| `reach` | string | `any`, `tenant` or `system`. |
| `role` | string | The lowest built-in role. |

### ApprovalVote

One approval given.

| Field | Type | Description |
| --- | --- | --- |
| `at` | integer (int64) | When, in seconds since the Unix epoch. |
| `by` | string | Who approved. |

### OidcMethod

The OpenID Connect provider this daemon trusts.

| Field | Type | Description |
| --- | --- | --- |
| `issuer` | string | Its issuer. |

### Holder

A token holder.

| Field | Type | Description |
| --- | --- | --- |
| `actor` | string | The actor in the audit chain: the name with its tenant. |
| `bound` | boolean | Whether it is bound to a client certificate's key (sender-constrained). |
| `expires` | integer (int64), nullable | When it stops working, in seconds since the Unix epoch. |
| `issued` | integer (int64), nullable | When, in seconds since the Unix epoch. |
| `issued_by` | string, nullable | Who issued it, for an issued token. |
| `name` | string | The name. |
| `role` | string | The role: built-in or a custom role of the access policy. |
| `scope` | [TokenScope](#schema-tokenscope), nullable | What the token may reach, when it is scoped. |
| `source` | string | `file` or `issued`. |
| `tenant` | string | The tenant, `default`, or `*` for the cross-tenant role. |

### AccessGrant

Route patterns and the operations allowed on them.

| Field | Type | Description |
| --- | --- | --- |
| `operations` | array of string | Operations, such as `key.sign` or `key.*`. |
| `paths` | array of string | Route patterns, such as `/v1/keys/payments-*/**`. |
