-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Support @PermissionAllowed for @BeanParam parameter #43231
Comments
/cc @pedroigor (bearer-token) |
cc @FroMage |
I think we should do that. Will put this on my list. One thing I am not sure is |
IMHO the parameter-naming conventions should be the same, regardless if it is a directly defined method-parameter or capsulated in a BeanParam. @GET
@Path("{id}/2params")
@PermissionsAllowed(value = "read", permission = OrganizationUnitIdPermission.class, params = "id")
public OrganizationUnit find2(@PathParam("id") UUID aOrganizationUnitId, @QueryParam("second") UUID aSecondUUIDParam) {
...
} I just checked: using |
yeah, honestly, I really hoped your example was a typo. I wrote decent Javadoc to it that describes expected behavior https://github.com/quarkusio/quarkus-security/blob/main/src/main/java/io/quarkus/security/PermissionsAllowed.java#L156 I think I forgot to add validation exception when TL;DR; it's documented and works for you as expected, but I think we need to inform user if he specifically types I'll add it when I get to implementing this issue (which won't be immediately). It's more of user experience improvement than bug. |
I'd expect you can just drop |
👍 |
Seeing this, I'm curious about how you populate your user's permissions. Out of curiosity, @ChMThiel how do you add the permissions to you user identity for all the |
@michalvavrik agreed. |
We are currently workin on a POC for restricting User's access to certain OrganizationUnits. Which user may acces what will be stored in a DB. |
OK, so you have those stored in your DB, so they're in your model. Thanks. |
@ChMThiel The JAX-RS parameter name is the bean parameter name, I'm not sure we have to start unwrapping it
Why ? The custom permission class is not a JAX-RS thing. What is difficult or not dev friendly about accessing a query parameter as |
Without unwrapping we need a separate Permission-Class for each BeanBaram-Class containing the parameter (in my example 'aOrganinzationUnitId'). |
I see, I got it now, thanks @ChMThiel, @michalvavrik |
It's almost as if I wrote it :-D +1 |
Description
A JAX-RS endpoint can be secured with a custom Permission with @PermissionAllowed annotation. Which parameters of the JAX-RS-method are passed to the Permission-constructor can be defined with the params-property of the PermissionAllowed annotation.
In following example the path-param 'id' UUID-param is passed to the Permission-class constructor-param 'aOrganizationUnitId'.
This works currently not with @BeanParam parameters. The attempt to secure a BeanParam-JAX-RS method like here:
fails with
There is afaik no way to bind the beanParam-property of the JAX-RS-method to the constructor-param of the Permission.
Implementation ideas
No response
The text was updated successfully, but these errors were encountered: