Skip to content

Commit

Permalink
Do not require RoutingContext outside or RESTEasy handler
Browse files Browse the repository at this point in the history
(cherry picked from commit 36bfe4c)
  • Loading branch information
michalvavrik authored and gsmet committed Jan 26, 2024
1 parent d802748 commit 3dcf570
Showing 1 changed file with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import io.quarkus.security.Authenticated;
import io.quarkus.security.PermissionsAllowed;
import io.quarkus.security.spi.runtime.AuthorizationController;
import io.vertx.ext.web.RoutingContext;
import io.quarkus.vertx.http.runtime.CurrentVertxRequest;

/**
* Security checks for RBAC annotations on endpoints are done by the {@link EagerSecurityFilter}, this interceptor
Expand All @@ -30,12 +30,14 @@ public abstract class StandardSecurityCheckInterceptor {
AuthorizationController controller;

@Inject
RoutingContext routingContext;
CurrentVertxRequest currentVertxRequest;

@AroundInvoke
public Object intercept(InvocationContext ic) throws Exception {
if (controller.isAuthorizationEnabled()) {
Method method = routingContext.get(EagerSecurityFilter.class.getName());
// RoutingContext can be null if RESTEasy is used together with other stacks that do not rely on it (e.g. gRPC)
// and this is not invoked from RESTEasy route handler
if (controller.isAuthorizationEnabled() && currentVertxRequest.getCurrent() != null) {
Method method = currentVertxRequest.getCurrent().get(EagerSecurityFilter.class.getName());
if (method != null && method.equals(ic.getMethod())) {
ic.getContextData().put(SECURITY_HANDLER, EXECUTED);
}
Expand Down

0 comments on commit 3dcf570

Please sign in to comment.