alichoopani

alichoopani

Role-based and Access-based Authorization in Phoenix controller

I am currently working on an Elixir application and I would like to implement role-based and access-based authorization. In Spring Security, there is a convenient syntax using the @PreAuthorize annotation. However, I couldn’t find a similar syntax in Elixir. Are there any libraries or approaches that can help me achieve this kind of authorization in Elixir?

In Spring Security, I could use @PreAuthorize("hasRole('ROLE_ADMIN')") to restrict access to certain roles. Is there a comparable way to achieve this in Elixir, perhaps with a similar syntax? For example, something like @security(roles: [:admin] or privileges: [:write]).

I would appreciate any guidance on how to implement role-based and access-based authorization in Elixir, along with any recommended libraries or approaches. Thank you.

Most Liked

woylie

woylie

In addition to Canada and Canary, Bodyguard and LetMe are worth mentioning. Although the latter was written by me, so I might be biased.

KristerV

KristerV

i looked into this recently. i ended up using Canada because it’s simple and just what i need. but Canary does more what you asked for.

there’s a few more options, but watch out for abandoned libraries!

Where Next?

Popular in Questions Top

RisingFromAshes
I’ve read in another post that it may be possible with a router helper - but I couldn’t find an appropriate one, and tbh, I’m still just ...
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" => #BSON.ObjectId<58eb1a7a9ad169198c3dXXXX>, "email" => ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New

Other popular topics Top

hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New
AstonJ
Posting this to see if we can make things easier for people to get into Neovim. If you use Neovim and have a favourite distro please let ...
New

We're in Beta

About us Mission Statement