# Revoking Access

A **Lock** blocks a target cluster-wide as soon as Auth propagates it. Locks are independent of certificate TTL: a user whose certificate is still valid is blocked immediately once a matching lock is in force.

Locks do not delete the SSO identity or rotate the cluster CA. For CA rotation after a suspected full compromise, see [CA Rotation](https://almaforge.com/ca-rotation.md).

## TL;DR[​](#tldr "Direct link to TL;DR")

Lock a user:

******Terminal

```bash
alma create lock --target-user=<name> --message="Incident IR-42"
```

Set an automatic expiry:

******Terminal

```bash
alma create lock --target-user=<name> --lock-ttl=4h --message="Pending review"
```

List active locks:

******Terminal

```bash
alma get lock
```

Capture the lock details for the incident record:

******Terminal

```bash
alma get lock/<name> -o yaml
```

Remove a lock:

******Terminal

```bash
alma delete lock/<name>
```

## What locks do and do not do[​](#what-locks-do-and-do-not-do "Direct link to What locks do and do not do")

**Locks do:**

* Block new certificate issuance, session starts, and API operations for the matched target.
* Take effect as each Proxy and agent receives the lock, typically within seconds over a healthy Auth connection. The [locking mode](#how-locks-propagate) governs access during an Auth disconnection. In `strict` mode, services deny access after more than five minutes without a successful lock refresh. In `bestEffort` mode, services continue enforcing the cached lock set.
* Terminate monitored connections when their service receives a matching lock, without waiting for the user to run another command.

**Locks do not:**

* Delete the user's SSO identity or [`OIDCConnector`](https://almaforge.com/reference/configuration.md#oidcconnector) mapping.
* Revoke certificates that have already been issued. The lock intercepts them at use time.
* Rotate the cluster CA. Use [CA Rotation](https://almaforge.com/ca-rotation.md) when certificates may have been exfiltrated and the CA itself must be replaced.

Revoke access granted outside AlmaForge, such as direct target credentials, in the system that grants it.

## Lock targets[​](#lock-targets "Direct link to Lock targets")

Each flag scopes the lock to a different target type. A lock matches any session or operation whose principal matches at least one target.

| Target         | Flag                      | When to use                                                                                                     |
| -------------- | ------------------------- | --------------------------------------------------------------------------------------------------------------- |
| User           | `--target-user=<name>`    | Block a specific SSO-mapped user by their cluster username. Use this first during an incident.                  |
| Role           | `--role=<name>`           | Block everyone with a given role. Useful when a role assignment was over-provisioned or a group is compromised. |
| Login (UNIX)   | `--target-login=<name>`   | Block a specific UNIX login name on SSH targets regardless of which user holds it.                              |
| Server         | `--server-id=<uuid>`      | Block access to a specific server. Use when the node itself is under investigation.                             |
| Access request | `--access-request=<uuid>` | Revoke an approved access request before the elevated session expires.                                          |

You can combine `--message` with any target flag to set a reason string shown to the locked-out user. Keep the message factual and incident-safe because the denial includes the matched target and the message text.

## Issue a lock[​](#issue-a-lock "Direct link to Issue a lock")

### Lock a user[​](#lock-a-user "Direct link to Lock a user")

******Terminal

```bash
alma create lock --target-user=alice --message="Incident IR-42: investigation in progress"
Created a lock with name "7f3d8a2c-...".
```

### Lock a role[​](#lock-a-role "Direct link to Lock a role")

******Terminal

```bash
alma create lock --role=db-admin --message="Role over-provisioned, pending audit"
```

### Lock a server[​](#lock-a-server "Direct link to Lock a server")

******Terminal

```bash
alma create lock --server-id=<node-uuid> --message="Node under investigation"
```

To find the server UUID:

******Terminal

```bash
alma get server
```

## Lock TTL[​](#lock-ttl "Direct link to Lock TTL")

By default a lock has no expiry and must be removed manually.

Use `--lock-ttl` to set a duration from now:

******Terminal

```bash
alma create lock --target-user=alice --lock-ttl=8h --message="Pending HR review"
```

Use `--expires` to set an absolute RFC3339 time:

******Terminal

```bash
alma create lock --target-user=alice --expires=2026-07-01T09:00:00Z --message="Pending HR review"
```

`--lock-ttl` and `--expires` are mutually exclusive. When neither is set, the lock remains until you delete it with `alma delete lock/<name>`.

## How locks propagate[​](#how-locks-propagate "Direct link to How locks propagate")

Auth holds the authoritative lock set. Proxies and agents subscribe to Auth's event stream through a lock watcher. When you create a lock, Auth notifies all watchers immediately over that stream.

Check the cluster locking mode:

******Terminal

```bash
alma get authconfig
```

The default locking mode is `bestEffort`. Set `spec.lockingMode` on the cluster `AuthConfig` resource named `cluster` to `strict` when you want stale lock views to fail closed, then apply the updated resource with `alma apply -f <authconfig.yaml>`.

* Under normal conditions propagation is near-instant.
* If a watcher loses its Auth connection, it retains the last known lock set. The watcher marks itself stale after 5 minutes without a successful refresh. In `strict` locking mode, a stale watcher denies access. In `bestEffort` mode, stale watchers allow access using the cached view.
* A connection monitor terminates its connection when it receives a matching lock event. Other access paths check locks when authorizing a new request or connection.

## Confirm the lock in audit[​](#confirm-the-lock-in-audit "Direct link to Confirm the lock in audit")

Creating a lock emits a `LockCreate` event in the audit log. Deleting a lock emits a `LockDelete` event.

Query your audit sink or SIEM for `spec.type=LockCreate` (`code=TLK00I`) and `spec.type=LockDelete` (`code=TLK01I`). Bound the query to the incident window so that older stale locks do not look like new revocations.

Each `LockCreate` event records `spec.type`, `spec.code`, `spec.timestamp`, the lock's name in `spec.objectRef.name`, who made it in `spec.actor.name`, and what it locks in `spec.lockCreate.target`. The lock resource records `message`, `expiresAt`, `createdAt`, and `createdBy`, so preserve both the audit event and `alma get lock/<name> -o yaml` output in the incident record.

## Remove a lock[​](#remove-a-lock "Direct link to Remove a lock")

List locks to find the name:

******Terminal

```bash
alma get lock
```

Delete by name:

******Terminal

```bash
alma delete lock/<name>
```

Deletion emits a `LockDelete` event in the audit log.

## Cleanup policy[​](#cleanup-policy "Direct link to Cleanup policy")

Locks without an expiry remain active until deleted. Review active locks on a regular operations cadence:

******Terminal

```bash
alma get lock
```

Track the active lock count in your operations dashboard or incident review report. A non-expiring lock should have an owner, an incident reference, and a cleanup decision.

## When to rotate the CA instead[​](#when-to-rotate-the-ca-instead "Direct link to When to rotate the CA instead")

A lock blocks access at use time but does not invalidate issued certificates. If you suspect that a certificate was exfiltrated and could be used outside the cluster (for example, against a target that accepts the cluster CA directly), a lock alone is not sufficient.

Rotate the CA to force all certificate holders to re-authenticate through your IdP. See [CA Rotation](https://almaforge.com/ca-rotation.md).

## Incident-response runbook[​](#incident-response-runbook "Direct link to Incident-response runbook")

Use this sequence for a suspected account compromise.

### 1. Lock the user immediately[​](#1-lock-the-user-immediately "Direct link to 1. Lock the user immediately")

******Terminal

```bash
alma create lock --target-user=<name> --message="IR-<number>: account suspected compromised"
```

### 2. Check for active access requests[​](#2-check-for-active-access-requests "Direct link to 2. Check for active access requests")

******Terminal

```bash
alma request ls
```

Revoke any approved requests held by the user:

******Terminal

```bash
alma create lock --access-request=<uuid> --message="IR-<number>: revoked pending investigation"
```

### 3. Identify and lock any over-provisioned roles[​](#3-identify-and-lock-any-over-provisioned-roles "Direct link to 3. Identify and lock any over-provisioned roles")

If the incident involves a role with broader access than expected, lock the role before you revise the OIDCConnector claim mapping:

******Terminal

```bash
alma create lock --role=<role-name> --message="IR-<number>: role locked pending review"
```

Keep the role lock in force while you remove the IdP group mapping from the OIDCConnector. Verify the stored connector no longer maps that group:

******Terminal

```bash
alma get oidcconnector/<name> -o yaml
```

Then test a fresh login through the normal Proxy path. Only delete the role lock after the fresh login no longer receives the role and previously issued credentials carrying it have expired or are blocked by another applicable lock. Removing the mapping does not rewrite existing certificates.

### 4. Pull recent session recordings[​](#4-pull-recent-session-recordings "Direct link to 4. Pull recent session recordings")

List recordings for the incident window:

******Terminal

```bash
alma recording ls --last=24h --limit=100
```

Replay any relevant session:

******Terminal

```bash
alma recording play <session-id>
```

The recording list is time-bounded, not user-filtered. Correlate session IDs with `SessionStart` and `SessionEnd` audit events for the user in your audit sink.

### 5. Rotate the CA for full compromise[​](#5-rotate-the-ca-for-full-compromise "Direct link to 5. Rotate the CA for full compromise")

If certificates may have left the cluster boundary, rotate the CA after the account is locked. See [CA Rotation](https://almaforge.com/ca-rotation.md) for the step-by-step procedure.

### 6. Confirm and record[​](#6-confirm-and-record "Direct link to 6. Confirm and record")

Verify the lock is in place:

******Terminal

```bash
alma get lock
```

Verify the audit trail in your audit sink or SIEM for the incident window. Capture both `LockCreate` and `LockDelete` events when a temporary lock has already been removed.

Record the lock names, incident reference, creation time, operator, session IDs, and recording locations in your incident log.

## References[​](#references "Direct link to References")

* [Break-Glass Access](https://almaforge.com/break-glass.md) - emergency CLI access when normal sign-in is unavailable.
* [CA Rotation](https://almaforge.com/ca-rotation.md) - rotate the cluster CA after a full compromise.
* [RBAC](https://almaforge.com/rbac.md) - role and OIDCConnector configuration.
* [CLI Reference](https://almaforge.com/reference/cli.md) - lock, resource, and recording commands.
* [Audit Reference](https://almaforge.com/reference/audit.md) - event catalog and recorded session reference.
