AutoPacker-OSS / autopacker

MIT License
6 stars 1 forks source link

Introduce organization-wide roles #144

Closed strazdinsg closed 3 years ago

strazdinsg commented 3 years ago

Instead of having simple ADMIN and MEMBER roles, we need to extend the roles for organizations.

Suggested naming of roles:

This issue would involve implementing the roles in the AuthorizationService. Implementation of necessary role check in the backend and frontend will be separate issues.

strazdinsg commented 3 years ago

@ANicholasson @MrPrecise Comments on role naming and logic?

ANicholasson commented 3 years ago

I think it's good to prefix with ORG as it is mentioned.

For the logic part: Will need to add the roles to the general-api registered keycloak client. Will then have to get the IDs of the roles in keycloak or some value we can use to get the RoleRepresentation (probably the role name is enough actually). And add them to the database somehow. The logic for authorizing a organization user would be as followed.

  1. Check if the user trying to access the organization is part of that organization (has a reference)
  2. If the user has a reference, find the role that the user has for that organization

So will probably need a many-to-many relation between user and OrgRole (some table) and between user and org. Not sure how the database architecture should look like.

strazdinsg commented 3 years ago

After looking at the entity structure I see that there can be a much simpler system for organization membership management: many-to-many relationship between Organization and User, where the relationship also includes a role as a string. Will try to implement that and simplify the entities during the process.