braunse

braunse

Auval_office - a flexible AUthorization policy eVALuator

Hi ElixirForum,

I was looking for a library to help me implement authorization in a principled way, and looking around, I liked the simplicity of authorize, but I wanted to try out my own variation on the theme.

So yesterday I published auval_office, a flexible AUthorization policy eVALuator.

What’s in the box?

When you define a policy module like this:

defmodule My.Policy
  use AuvalOffice.Policy

  rule ...
  rule ...
  rule ...
end

then auval_office will augment your policy with an authorize function:

case My.Policy.authorize(subject, object, action) do
  {:ok, rule_id, parameters} -> # allowed
  {:error, rule_id, parameters} -> # not allowed
end

What’s different from other authorization packages?

  • auval_office is self-contained.

    It has no dependency on phoenix or ecto. It includes no plug for your web pipeline. You decide if authorization should be a domain responsiblity or a web layer responsibility, and where authorization-related data should be stored.

  • auval_office does not favor one access control model.

    It is flexible enough to implement lots of different access-control schemes, but favors none of them. I believe it offers enough flexibility to implement Role-Based Access Control (RBAC), Attribute-Based Access Control (ABAC) and Access Control Lists (ACLs), and combinations of those models.

  • auval_office justifies its decisions.

    The return value of the authorize function includes the ID of the rule that made the decision, and you can return parameters from the rule to augment that information. This enables the user to build historical audit trails, answering questions like “Who changed that data, and why was that allowed at the time?”

  • auval_office can consider context.

    The authorize function has an optional context parameter, where you can provide a map of additional information items to consider when making an authorization decision:

    My.Policy.authorizer(subject, object, action, %{moon_in_house: :seventh})
    

    auval_office also includes a fetcher facility, that enables you to fetch necessary context values at authorization time. Just include a fetch in your policy:

    defmodule My.Policy do
      use AuvalOffice.Policy
    
      fetch :fetch_user_group_memberships, :groups, subject: %User{id: id} do
        groups = Accounts.get_groups_by_user_id(id)
        {:ok, groups}
      end
    
      rule ...
    end
    

    Before evaluating the policy, auval_office will check if a :groups item is present in the context, and if not, will call the fetcher you defined to add the :groups to the context.

Links

Where Next?

Popular in Libraries Top

tmbb
I’ve been working on two packages (not on hex.pm yet) to build admin interfaces for phoenix apps: bureaucrat - which contains a bunch ...
New
mathieuprog
Hello :wave: Allow me to introduce you to Tz, an alternative time zone database support to Tzdata. Why another library? First and fore...
New
markmark206
simple_feature_flags is a tiny package that lets you turn features on or off based on which environment (e.g. localhost, staging, product...
New
achempion
Hi, I would like to tell about my initiative to further maintain and develop Waffle project which is the fork of Arc library. The progre...
New
michalmuskala
Hello everybody. I have just released Jason - a new JSON library. You might be wondering, why do we need a new library? The primary foc...
New
aditya7iyengar
Rummage.Ecto and Rummage.Phoenix provide ways to perform Searching, Sorting and Pagination over Ecto queries and Phoenix collections. Fo...
New
Crowdhailer
I have been updating a library that allows you to pipe between functions that use the erlang result tuple convention. Assuming you have...
New
benlime
LiveMotion enables high performance animations declared on the server and run on the client. As a follow up to my previous thread A libr...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 42633 214
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New

Other popular topics Top

shahryarjb
Hello, I get Persian date from my client and convert it to normal calendar like this: def jalali_string_to_miladi_english_number(persi...
New
peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod -- where is this set? Thanks.
New
freewebwithme
Using vs code and installed ElixirLS: support and debugger. And I got an error popped up on start up says Failed to run ‘elixir’ comma...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
vonH
When I run the Plug and I recompile I wind up having to use Ctrl C to quit iex and start again. Witht the help of rlwrap I can use the cu...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
beno
I will often find my self writing things similar to: case some_value do nil -> something() "" -> something() _ -> someth...
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New

Sub Categories:

We're in Beta

About us Mission Statement