Skip to content
/ oriza Public

A small library to add authorization to Elixir functions.

License

Notifications You must be signed in to change notification settings

rmparr/oriza

Repository files navigation

Oriza Coverage Status

A way to add contexts to function calls. Given:

defmodule MyModule do
  use Oriza.Context

  context(:do_something, [:arg], [admin: [:read, :write]])
  def do_something(arg), do: arg
end

Creates the following additional function definition:

def do_something(user_context, arg) do
  if check_context(user_context, %Oriza.Context{keys: [admin: [:read, :write]]}) do
    do_something(arg)
  else
    {:error, "access denied"}
end

Installation

Oriza can be added as a project dependency:

def deps do
  [
    {:oriza, "~> 0.0.3-alpha"}
  ]
end

After adding the dependency, modules can use Oriza, which will give access to the context macro.

Contributing

Git Hooks

GitHub Actions is going to run all of this anyway, so why not check before?

To remove any existing hooks and symlink the repo git hooks, run mix run scripts/symlink_git_hooks.exs from the command line.

About

A small library to add authorization to Elixir functions.

Topics

Resources

License

Stars

Watchers

Forks