forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make @testsecurity work correctly with unannotated JAX-RS endpoints s…
…ecurity feature The use of `quarkus.security.jaxrs.deny-unannotated-endpoints=true` essentially results in the addition of a `DenyAllInterceptor` to the invocation chain of a JAX-RS endpoint. Because this interceptor did not take into account the `AuthorizationController` (like the `RolesAllowedInterceptor` already does), it would result in endpoints being secured even though security was supposed to be disabled for the specific test. Fixes: quarkusio#19896 (cherry picked from commit b9359bf)
- Loading branch information
Showing
3 changed files
with
12 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,6 +7,8 @@ | |
import javax.interceptor.Interceptor; | ||
import javax.interceptor.InvocationContext; | ||
|
||
import io.quarkus.security.spi.runtime.AuthorizationController; | ||
|
||
/** | ||
* | ||
* @author Michal Szynkiewicz, [email protected] | ||
|
@@ -19,8 +21,15 @@ public class DenyAllInterceptor { | |
@Inject | ||
SecurityHandler handler; | ||
|
||
@Inject | ||
AuthorizationController controller; | ||
|
||
@AroundInvoke | ||
public Object intercept(InvocationContext ic) throws Exception { | ||
return handler.handle(ic); | ||
if (controller.isAuthorizationEnabled()) { | ||
return handler.handle(ic); | ||
} else { | ||
return ic.proceed(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters