-
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
RestEasy Reactive performs authorization checks twice #26536
Comments
/cc @FroMage, @geoand, @stuartwdouglas |
/cc @sberyozkin |
@geoand Can |
Ive looked at the code and I guess just dropping this handler may not be a good idea, but it looks like it might be possible to avoid doing the authorization checks specifically. |
I'll have a look later this week, busy with my work now. |
I am pretty sure we want this to be the other way around - the code in |
Agreed, it does not make sense to do check twice. |
The only question is where to do these checks, I thought |
It does, no question about that. My point is that we should have some kind of switch that make |
Not just on this one, on |
Yes, correct |
But what is the problem with not doing the authorization check at the |
We had multiple issues in RR with the security flow, which is why things were moved to |
@geoand Sure, have they been related to running |
I can't remember honestly, sorry |
@geoand Sorry, I don't mean to be annoying though I accept I might still be :-). What I think would be good though, once Michal finds time to check it out, is to figure out, if it is principally important to collocate both the authentication and authorization related code in this If the flag based solution is implemented, then I'm not sure what would it mean for the the custom security CDI interceptors in the RestEasy reactive flow, I guess we'd need to update the docs with some guidance as per @knutwannheden's comment (use ExceptionMapper for the exceptions, CDI interceptor for the accepted requests, etc). Either way, thanks for the patience Thanks |
Not a problem at all :). I can certainly try and dig up the old issues we had. |
Hi @geoand Yeah, it will work fine for sure and will most likely be the simplest fix, I'm not trying to be pedantic. It is likely that the authorization checks have been done from this handler because there was some mis-sync with the CDI chain when it comes to running those existing sec interceptors. It is just a sense of uncertainty about running those existing (custom) sec interceptors in Resteasy reactive flows that would be good to clarify IMHO, at least indirectly by adding some docs... Thanks |
Completely understood. I'll try to dig up the history tomorrow |
Thanks @geoand :-), lets keep discussing when you get some time |
for record: security checks are performed twice when an RBAC annotation is on the endpoint, once when CDI bean method is annotated (by quarkus-security interceptor). |
I had another look at this yesterday and looked into using exception mappers to log the failed authorization checks and a CDI interceptor for successful authorizations. This asymmetry and the fact that it doesn't cover the case when authorization rules are defined using configuration properties (where I still haven't found a solution) lead me to create a feature request for an SPI: #26549 Using exception mappers to log the negative authorization check outcome also poses another problem for us: Since we aren't directly building an application, but a set of Quarkus extensions to be used by many applications in the inhouse development of an enterprise, the application developers would have to be careful to not inadvertently disable the security logging when registering their own exception mappers. Here the approach with the additive CDI interceptors is the better alternative for us. |
#19598 was the original change introducing the eager security feature. From the git history of |
FWIW, I am currently looking into the possibility of using a Vert.x handler (registered via |
Description
(I am filing this issue as an enhancement, because it isn't really a bug, but I suspect that performing the authorization twice isn't the desired behavior either.)
When using RestEasy Reactive the authorization checks will be performed twice: Once using RestEasy Reactive's own
EagerSecurityHandler
(registered as aServerRestHandler
) and once by the curresponding CDI interceptor (e.g.RolesAllowedInterceptor
) provided byquarkus-security
. It would seem like it would make sense to only perform the check once, as with RestEasy Classic.I stumbled across this while migrating to RestEasy Reactive, since we also use the CDI interceptor approach for some custom security logging. With RestEasy Reactive this mechanism no longer works in the "negative" case (when the authorization check fails), since the check performed by RestEasy Reactive will short-circuit the handling. As an alternative for the negative case I can however use an
ExceptionMapper
instead.Implementation ideas
No response
The text was updated successfully, but these errors were encountered: