Malachi.Auth.AclStore (malachi v0.22.7)

View Source

The cluster's per-topic ACL store: a thin facade over the ra-replicated ACL cluster (Malachi.Auth.AclServer), the counterpart of Malachi.Auth.UserStore. Malachi.Application starts the ra cluster at boot; this module routes grants/revokes through the log (consensus) and authorization reads to the local replica (:ra.local_query, fast and eventually consistent).

Summary

Functions

Whether username has a grant for operation on topic, from the local replica. Fails closed: an unreachable ACL store returns false (deny): authorization must not grant access it cannot verify.

The ACL cluster's ra cluster name.

Grants username an operation on resource. Returns :ok or {:error, reason}.

Every grant across all users as {username, operation, resource} (empty on error).

The grants for username as {operation, resource} (empty on error).

Revokes a single grant (idempotent). Returns :ok or {:error, reason}.

Revokes every grant for username (e.g. on user deletion). Returns :ok or {:error, reason}.

Functions

authorized?(username, operation, topic)

Whether username has a grant for operation on topic, from the local replica. Fails closed: an unreachable ACL store returns false (deny): authorization must not grant access it cannot verify.

cluster_name()

@spec cluster_name() :: atom()

The ACL cluster's ra cluster name.

grant(username, operation, resource)

Grants username an operation on resource. Returns :ok or {:error, reason}.

list_all()

@spec list_all() :: [Malachi.Auth.AclRegistry.grant()]

Every grant across all users as {username, operation, resource} (empty on error).

list_grants(username)

The grants for username as {operation, resource} (empty on error).

revoke(username, operation, resource)

Revokes a single grant (idempotent). Returns :ok or {:error, reason}.

revoke_user(username)

@spec revoke_user(String.t()) :: :ok | {:error, term()}

Revokes every grant for username (e.g. on user deletion). Returns :ok or {:error, reason}.