ppetrov

ppetrov

Scopes with custom authorization

Hello guys,

I am looking for an advise here. I am trying to build a system which will be tenant application with organizations and users. Under each organization there will be a dossier for a visitor/patient. Under it there will be other different types of records. The organization will have an owner which will be granting access to the different users via records in the database. For example Owner1 adds User2 grating full access as internal over all records under that organization. Or Owner1 adds User2 as external user which will have access only to a single dossier.

The access should be checked each time a dossier is opened under that organization with the assigned access level. If such does not exist the current user will be routed away with error.

Eventually not all users will be granted access over all records but only to few. Also some users would only have read-only permissions without the option to create/edit/delete records.

That is a simple example of what the app is suppose to do. The problem i am having is - should i use Scopes for the granular access or i should just build my own approach which eventually would overlap the Scope functionality to certain level. Or maybe a mix of both - Scopes and custom rules?

To me if i have the organization_rules table which will have the allowed user along with the either resource(s) or full access then the scope for organization might be redundant considering upon creation that field will be populated when being saved. Then when pulling the record and checking the access if the user can read/write etc. then maybe it does not need scopes. Or maybe i don’t understand the scopes very well and my goal can be achieved with it.

Any help is welcome here.

Marked As Solved

ppetrov

ppetrov

Solved by this topic.

Also Liked

garrison

garrison

Keep in mind that Scopes, like Contexts, are just a pattern rather than something innate to Phoenix as a framework. That’s why most of the documentation is about integrating with the generators rather than scopes themselves.

The point being: if you want to adjust that pattern to fit your needs, you can do so in any way you please. There are no rules.

Last Post!

garrison

garrison

Keep in mind that Scopes, like Contexts, are just a pattern rather than something innate to Phoenix as a framework. That’s why most of the documentation is about integrating with the generators rather than scopes themselves.

The point being: if you want to adjust that pattern to fit your needs, you can do so in any way you please. There are no rules.

Where Next?

Popular in Questions Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
Emily
I have VueJS GUIs with the project generated using Webpack. I have Elixir modules that will need to be used by the VueJS GUIs. I forese...
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
jay1
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
greenz1
I have a phoenix application from which a user can download multiple(5-6) files of size 1MB. I couldn’t find anything related to sending ...
New
svb
Hi! Currently I want to submit a form by pressing the Enter key. However, since my input field is of type “textarea” this is just adds a...
New
senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3271 130286 1222
New
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
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
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
chrismccord
Phoenix 1.4.0 released Phoenix 1.4 is out! This release ships with exciting new features, most notably with HTTP2 support, improved deve...
688 31494 112
New

We're in Beta

About us Mission Statement