Right now some authorization/permission related logic lives in the "frontend"/"web" part of the application.
It should be moved to the backend, maybe/probably into its own context Permissions or something similar. Theoretically every context can also provide functions to check its own permissions (as one context that depends on all others, is quite big) but permissions may often be cross cutting and in general an approach that centralizes these rules can often be good for the overview it provides.
This should also including scoping (i.e. taking a collection and scoping it down to the accessible records).
Why to the Backend?
The logic isn't entirely tied to the frontend/LiveView - if we had another way into the system, the logic would likely be the same
you should also never trust the FE as users can send whatever, so permissions should always be double checked on the backend side
generally speaking, the BE should also not depend on the FE, the FE should depend on the BE
at their core these are pure functions well suited for the BE
I don't think we need external libraries for that as our authorization logic is very very simple. I like the idea to move / extract the code in an own context though 👍
Right now some authorization/permission related logic lives in the "frontend"/"web" part of the application.
It should be moved to the backend, maybe/probably into its own context
Permissions
or something similar. Theoretically every context can also provide functions to check its own permissions (as one context that depends on all others, is quite big) but permissions may often be cross cutting and in general an approach that centralizes these rules can often be good for the overview it provides.This should also including scoping (i.e. taking a collection and scoping it down to the accessible records).
Why to the Backend?
Where are the permissions now?
They might be more scattered but right now a lot of them live in idea live: https://github.com/b310-digital/mindwendel/blob/aaa88c0f3a64c35a97d8c56e77e0b3fa8d4d0e5a/lib/mindwendel_web/live/live_helpers.ex#L6-L21
Libraries
There's a ton of libraries out there right now and I'm not entirely sure which one is best. A lot of them use more DSLs than I like but :shrug: