Closed DaveKram closed 1 year ago
Hi @DaveKram and thanks for reporting!
It's kind of related with this feature-request for rocket's version: https://github.com/DDtKey/rocket-grants/issues/3 in terms of OR / AND
functionality
In general, I'm going to do some large refactoring (merging crates into single repo, implement that feature and minor ones). However because of my bandwidth I'm not sure about timeline and it doesn't solve your case: different types of Role
& Permission
.
So, I agree, need to support multiple macros at the same time, it sounds reasonable.
@DDtKey thanks for the response. Totally understandable.
If I can also find time past my day job, I may investigate it a little.
Thanks for the work you do though, the crate has been useful otherwise. I'll close this out for now.
I don't mind keeping it open, maybe I'll look into it over the weekend.
@DaveKram could you try a new version (3.0.2
)?
I've added support & test https://github.com/DDtKey/actix-web-grants/blob/f419712e5f138958b331f04b80f7b50674e713d5/tests/proc_macro/type_feature.rs#L32-L38
@DDtKey thanks for taking a look at this! I've updated my code that was using that/testing all the roles/perms iteratively making REST calls to my endpoints, and it seems to work fine. No issues to report.
More of a question than an issue.
Was hoping to do something like the following:
`#[get("/read")]
[has_permissions("UserPermissions::UserRead")]
[has_any_role("UserRole::Admin", "UserRole::User")]`
where I can check 2 different types (a UserPermissions enumeration and a UserRole enumeration on a singular endpoint.
Aka, I'd like for the permission to be UserRead, but also the user's role to be either an Admin or a User.
Given the 2 approaches to macros (has or has_any), I can't shove all of these into the same enumeration to solve this? (since the has_permissions/has_roles would exclude the 'or' logic for the roles, and has_any_role/has_any_permission, would just return true if any one is true.
And so far what I can see, the has_any_role/hasroles proc macros are the same logic as the permissions ones, just looking for a ROLES prefix in the string.
Trying to do the above on a struct provides me with:
identifier
_authdetailsis bound more than once in this parameter list used as parameter more than once
Am I going about this/thinking about this wrong? I'd like to have a user role AND set of associated permissions checked.