Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add logic for processing array of resources (two ways) #47

Closed
ArdenHide opened this issue Aug 21, 2023 · 1 comment · Fixed by #46
Closed

Add logic for processing array of resources (two ways) #47

ArdenHide opened this issue Aug 21, 2023 · 1 comment · Fixed by #46
Assignees

Comments

@ArdenHide
Copy link
Member

ArdenHide commented Aug 21, 2023

Make new PK (Name + RoleId). (This PK can make user in his context)
It's allow situation when DB contain two resources with the same name, but with different role.

Example:

Roles:

  1. AdminRole
  2. SuperAdminRole

Resources:

  1. Name=OnlyAdminResource, RoleId = AdminRole
  2. Name=OnlyAdminResource, RoleId = SuperAdminRole

In this example, we allow only AdminRole and SuperAdminRole, to call OnlyAdminResource

Also, need to update ResourceManager in overrides which receive IEnumerable<TResource> resources need to check if these resources has the same name. This move need to prevent this situation:

Roles:

  1. UserRole
  2. AdminRole

Resources:

  1. Name=PublicResource, RoleId = UserRole
  2. Name=AdminResource, RoleId = AdminRole

User call PublicResource and AdminResource with override which receive IEnumerable<TResource> resources and receive true because least one resource allow (in this situation allowed PublicResource)

@ArdenHide ArdenHide self-assigned this Aug 21, 2023
@ArdenHide
Copy link
Member Author

But the above solution can be an incorrect way.

I see better way how to implement new logic:
Create overrides which can receive resources and instead of return boolean value true/false return array of resources which be allowed.

@ArdenHide ArdenHide changed the title Update Resources table Add logic for processing array of resources (two ways) Aug 21, 2023
@ArdenHide ArdenHide linked a pull request Aug 21, 2023 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant