Hex.pm Docs

Authorization superpowers for applications using Ecto.

Priorities:

Installation

Janus can be installed by adding ex_janus to your deps in mix.exs:

defp deps do
[
{:ex_janus, "~> 0.2.0"}
]
end

Why (not) Janus?

Janus was created to scratch an itch: the same rules that authorize loaded data should be able to load authorized data. In concrete terms, a rule that defines whether a user can edit a resource should also be able to load all the resources that user can edit.

Loading data this way should be:

  1. efficient - loading everything and then filtering it in-memory doesn't cut it;

  2. composable - it should be possible to add additional conditions when loading data;

  3. ergonomic - authorization should slot-in naturally without major rewrites.

Thankfully, integration with Ecto.Query solves for all of the above. One only needs authorization rules that can be translated into a query.

And thus, Janus was born.

Janus may be a good fit if...

Janus may not be a good fit if...

Documentation

If you're reading this on GitHub, head over to the HexDocs.

If you're already on HexDocs, here's where you might head next:

Development

To set up and test Janus locally:

$ git clone https://github.com/zachallaun/ex_janus && cd ex_janus
$ mix deps.get
# Set up test database and run tests with code coverage report
$ mix setup
$ mix t