b310-digital / mindwendel

Create a challenge. Ready? Brainstorm. mindwendel helps you to easily brainstorm and upvote ideas and thoughts within your team.
https://www.mindwendel.com
GNU Affero General Public License v3.0
82 stars 13 forks source link

Move authorization logic to the backend #455

Open PragTob opened 1 week ago

PragTob commented 1 week ago

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:

JannikStreek commented 3 days ago

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 👍