I'm following JWT guide for quarkus here. I want to send custom response when UserGroup is not allowed to access an api.
This is the sample shown in the guide.
@GET()
@Path("roles-allowed")
@RolesAllowed({"Echoer", "Subscriber"})
@Produces(MediaType.TEXT_PLAIN)
public String helloRolesAllowed(@Context SecurityContext ctx) {
Principal caller = ctx.getUserPrincipal();
String name = caller == null ? "anonymous" : caller.getName();
boolean hasJWT = jwt != null;
String helloReply = String.format("hello + %s, isSecure: %s, authScheme: %s, hasJWT: %s", name, ctx.isSecure(), ctx.getAuthenticationScheme(), hasJWT);
return helloReply;
}
How do i know if the request is unauthorized so that i can send custom response.