AshVault.Macaroon.KeyWindow behaviour (AshVault v0.2.0)

Copy Markdown View Source

Behaviour for a dynamic accepted_key_versions: how many recent :mac key versions a scope accepts, decided at verify time.

accepted_key_versions MyApp.Macaroons.WindowByTenant
accepted_key_versions {MyApp.Macaroons.WindowByTenant, default: 1}
accepted_key_versions {MyApp.Macaroons, :window, []}   # MFA, called with scope first

A module (optionally with opts) or an MFA, never an inline function: the window is a security boundary evaluated for every verification, and belongs in named, testable code.

accepted_key_versions/2 receives the token's scope and returns a positive integer or :all. Anything else — or a raise — fails closed to 1: only the current key version is accepted.

Summary

Callbacks

The number of recent :mac key versions scope accepts, or :all.

Callbacks

accepted_key_versions(scope, opts)

@callback accepted_key_versions(scope :: binary(), opts :: keyword()) ::
  pos_integer() | :all

The number of recent :mac key versions scope accepts, or :all.