io.quarkus.qe.UserResource Maven / Gradle / Ivy
package io.quarkus.qe;
import jakarta.annotation.security.RolesAllowed;
import jakarta.inject.Inject;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;
import org.eclipse.microprofile.jwt.JsonWebToken;
import io.quarkus.security.identity.SecurityIdentity;
@Path("/user")
@RolesAllowed("test-user-role")
public class UserResource {
@Inject
SecurityIdentity identity;
@Inject
JsonWebToken jwt;
@GET
@Produces(MediaType.TEXT_PLAIN)
public String get() {
return "Hello, user " + identity.getPrincipal().getName();
}
@GET
@Path("/issuer")
@Produces(MediaType.TEXT_PLAIN)
public String issuer() {
return "user token issued by " + jwt.getIssuer();
}
}