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

Use final SecurityIdentity augmented with all the augmentors in @PermissionChecker methods #45012

Conversation

michalvavrik
Copy link
Member

@michalvavrik michalvavrik commented Dec 9, 2024

@michalvavrik michalvavrik force-pushed the feature/apply-perm-check-on-final-identity branch from 8ad878a to 8f44d0d Compare December 9, 2024 16:53
Copy link

quarkus-bot bot commented Dec 9, 2024

Status for workflow Quarkus CI

This is the status report for running Quarkus CI on commit 8f44d0d.

✅ The latest workflow run for the pull request has completed successfully.

It should be safe to merge provided you have a look at the other checks in the summary.

You can consult the Develocity build scans.

@sberyozkin
Copy link
Member

Thanks @michalvavrik , will have a look tomorrow, finding it difficult to review on the phone

@michalvavrik
Copy link
Member Author

Thanks @michalvavrik , will have a look tomorrow, finding it difficult to review on the phone

I can only imagine :-D We are in no hurry.

@@ -206,7 +207,11 @@ public Builder addProvider(IdentityProvider<? extends AuthenticationRequest> pro
* @return this builder
*/
public Builder addSecurityIdentityAugmentor(SecurityIdentityAugmentor augmentor) {
augmentors.add(augmentor);
if (augmentor instanceof QuarkusPermissionSecurityIdentityAugmentor quarkusPermissionAugmentor) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @michalvavrik The fact that we have to modify this class in a couple of places to do some special processing around the internal security augmentor implies, IMHO, that may be that original solution has to be revisited. Recall we discussed it.

Would it simplify things, if, instead of having the special internal QuarkusPermission and the special augmentor, we'd make this QuarkusPermission be an actual custom permission that will be passed to possessed permissions ? I believe the reason we have the current solution is that it was meant to make it easier for users to correctly write custom permission checkers, but we now have addPermission(...) identity builder methods...

We don't have to do it now as the bug has to be fixed, and it may require more discussion, but at least I'd ask for //Revisit comments

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@michalvavrik I can open an enhancement or housekeeping issue for us to discuss. QuarkusPermissionSecurityIdentityAugmentor plus current QuarkusPermission combination is sound, but I hope we can avoid doing QuarkusPermissionSecurityIdentityAugmentor specific processing...
Thanks

Copy link
Member Author

@michalvavrik michalvavrik Dec 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't mind rewriting this at all, I'll do it if you insist. IMO will not gain anything. What you see is in this PR is internal Quarkus Security code and following operations needs to be done in one way or another:

  • we need to augment security identity (hence the augmentor)
  • we need add permission checker in that augmentor

We can drop QuarkusPermissionSecurityIdentityAugmentor and QuarkusPermission and call it differently, but nothing will change from the perspective of what the code does. This PR could had been avoided 100 % if the SecurityIdentity is taken from Arc, but that has following downsides:

  • it requires more operations (call Arc, whatver it does inside and the identity is proxy itself)
  • I think it could be a blocking operation at some scenarios, we can improve that to avoid it (because obviously we will have the identity for authorization, but ATM that can be a case)

QuarkusPermission be an actual custom permission that will be passed to possessed permissions ?

I think QuarkusPermission is actual required permission and if it is passed to a possessed permission, you need:

  • add new possessed permission in augmentor (that we already do)
  • get the identity from somewhere (probably arc, see above my comments)

So I respect that changes in this PR can look bad, we can avoid such exceptions if it needs to be done.

@sberyozkin sberyozkin self-requested a review December 10, 2024 13:32
@sberyozkin sberyozkin merged commit 90dc755 into quarkusio:main Dec 10, 2024
32 checks passed
@quarkus-bot quarkus-bot bot added this to the 3.18 - main milestone Dec 10, 2024
@michalvavrik michalvavrik deleted the feature/apply-perm-check-on-final-identity branch December 10, 2024 14:34
@gsmet gsmet modified the milestones: 3.18 - main, 3.17.4 Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants