-
Notifications
You must be signed in to change notification settings - Fork 15
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
Update SecurityIdentity to list owned Permissions and allow simpler permission checks #57
base: main
Are you sure you want to change the base?
Update SecurityIdentity to list owned Permissions and allow simpler permission checks #57
Conversation
…permission checks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I kinda said it all in my comments in quarkusio/quarkus#43717. I can't think of anything else to comment here.
FWIW idea to add addPermission
to the QuarkusSecurityIdentity.Builder
is brilliant.
src/main/java/io/quarkus/security/identity/SecurityIdentity.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Michal Vavřík <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like a good idea.
@michalvavrik Michal, I've totally missed Steph approved, what should we do here, I'm assuming you are OK with keeping a method allowing to list current permissions. I can drop the methods for checking them, it can be done later, but indeed, letting users list posessed permissions seems useful, similarly to what users can do with |
Honestly, I am still worried that users will consider following interchangeable:
(it's metacode, don't take it literately please). Because that is what we ourselves do in Quarkus, we mostly (if not always) use If you said in the |
Sorry Michal, I did not quite get your concern about the interchangeable code above, it does look interchangeable to me or did I miss something ? |
I don't know, it quite hard for me to explain it because I am not sure where we disagree. I can try again, I hope I am not repeating myself and it is useful:
is not interchangeable because you can do for example this: If users or Quarkus or Quarkiverse extensions add these checkers, they are not |
Thanks @michalvavrik I'll think about your comment and reply a bit later, this PR is not essential for the next release |
The main purpose of this PR is to make it possible to simplify the way
@PermissionAllowed
are enforced by default at the Quarkus level.At the Quarkus level, when no (recently introduced)
@PermissionChecker
is used, the only way for users to have@PermissionAllowed
checks enforced is basically do these checks themselves by registering a customSecurityidentityAugmentor
and adding a custom permission checker function:For example (from the Quarkus docs):
Where the users need to correctly write the permission checker function making sure it is permission which is meant to be associated with the identity is used to call
implies
, not the required one... And there is no way to check onSecurityIdentity
which permissions it owns.@FroMage and @michalvavrik worked out a plan to make it easier to implement such functions, but IMHO users should be totally shielded from having to write such checkers. We do not ask users to manually write role checks, and we should not ask them to do it for permissions. They can do if they really want to, but it should be avoidable.
The above code should look like this:
And Quarkus Security will do the required checks itself, by checking
SecurityIdentity#getPermissions()
added in this PR.See also quarkusio/quarkus#43717