# 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

- `Parc.Request`: the Principal/Action/Resource/Context request.
- `Parc.RequestPreparer`: a step that enriches the request or aborts
  with an error, but cannot decide a verdict.
- `Parc.PolicyDecider`: the decision point that returns an allow,
  deny, challenge, or error verdict.
- `Parc.Pipeline`: runs the preparers, then the decider.

## Usage

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

```elixir
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`:

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

The API reference is at [hexdocs.pm/parc](https://hexdocs.pm/parc).
