Parc

PARC (Principal, Action, Resource, Context) is the shape of an authorization request: who is asking to do what to which resource in what context. Parc models that request and the decision over it, independent of any policy framework.

A pipeline prepares the request, then one decision point judges it, so a policy is declared once and driven from any entry point.

Contract

Usage

Declare a policy pipeline, then run a request through it:

defmodule MyApp.Policy do
use Parc.Pipeline
prepare MyApp.Preparers.Clock, key: :now
decide MyApp.Decider
end
MyApp.Policy.run(request)

Preparers run in declaration order; the first {:error, _} short-circuits and skips the decider. A pipeline has exactly one decider, enforced at compile time.

Installation

Add parc to your dependencies in mix.exs:

def deps do
[
{:parc, "~> 0.1"}
]
end

The API reference is at hexdocs.pm/parc.