https://github.com/rmparr/oriza
A small library to add authorization to Elixir functions.
https://github.com/rmparr/oriza
authorization elixir
Last synced: 4 months ago
JSON representation
A small library to add authorization to Elixir functions.
- Host: GitHub
- URL: https://github.com/rmparr/oriza
- Owner: rmparr
- License: other
- Created: 2021-04-11T17:28:58.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2021-05-20T08:51:01.000Z (about 5 years ago)
- Last Synced: 2026-02-12T03:43:47.393Z (4 months ago)
- Topics: authorization, elixir
- Language: Elixir
- Homepage:
- Size: 28.3 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Oriza [](https://coveralls.io/github/rmparr/oriza?branch=main)
A way to add contexts to function calls. Given:
```elixir
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:
```elixir
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:
```elixir
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.