package fr.la_banquise.backend; import jakarta.annotation.security.RolesAllowed; import jakarta.ws.rs.GET; import jakarta.ws.rs.Path; import jakarta.ws.rs.Produces; import jakarta.ws.rs.core.Context; import jakarta.ws.rs.core.MediaType; import jakarta.ws.rs.core.Response; import jakarta.ws.rs.core.SecurityContext; import io.quarkus.security.Authenticated; @Path("/api/user") @Authenticated public class UsersResource { @GET @Path("/me") @Produces(MediaType.APPLICATION_JSON) @RolesAllowed("user") // public Response> me(@Context SecurityContext // securityContext) { public Response me() { // OidcJwtCallerPrincipal principal = (OidcJwtCallerPrincipal) // securityContext.getUserPrincipal(); // Map claims = principal.getClaims().getClaimsMap(); // System.out.println(claims); // Map userInfo = new HashMap<>(); // userInfo.put("username", claims.get("name")); // userInfo.put("username", "malo"); // userInfo.put("email", token.getEmail()); // userInfo.put("firstName", token.getGivenName()); // userInfo.put("lastName", token.getFamilyName()); String test = "yess"; return Response.ok(test).build(); } // @Inject // SecurityIdentity identity; // // @GET // @Path("/me") // public User me() { // return new User(identity); // } // // public static class User { // private final String userName; // private final Set roles; // private final String sshKey; // // User(SecurityIdentity identity) { // this.userName = identity.getPrincipal().getName(); // this.roles = identity.getRoles(); // // if (identity.getPrincipal() instanceof OidcJwtCallerPrincipal) { // OidcJwtCallerPrincipal oidcJwtCallerPrincipal = (OidcJwtCallerPrincipal) // identity.getPrincipal(); // // Map claims = // oidcJwtCallerPrincipal.getClaims().getClaimsMap(); // // System.out.println(claims.get("ssh-key")); // this.sshKey = (String) oidcJwtCallerPrincipal.getClaim("ssh-key"); // } else { // this.sshKey = null; // } // } // // public String getUserName() { // return userName; // } // // public Set getRoles() { // return roles; // } // // public String getSshKey() { // return sshKey; // } // } }