Add claims kid

This commit is contained in:
Valentin CZERYBA 2022-05-13 21:01:31 +02:00
parent 675c6a0d6b
commit 39ad985eae

View File

@ -21,7 +21,7 @@ import io.smallrye.jwt.auth.principal.JWTParser;
import io.smallrye.jwt.auth.principal.ParseException; import io.smallrye.jwt.auth.principal.ParseException;
import io.smallrye.jwt.build.Jwt; import io.smallrye.jwt.build.Jwt;
import org.eclipse.microprofile.jwt.Claims;
import org.eclipse.microprofile.jwt.JsonWebToken; import org.eclipse.microprofile.jwt.JsonWebToken;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import org.jboss.resteasy.annotations.jaxrs.HeaderParam; import org.jboss.resteasy.annotations.jaxrs.HeaderParam;
@ -57,7 +57,7 @@ public class TokenRessource {
if(password.equals(users.password)){ if(password.equals(users.password)){
// Create a JWT token signed using the 'HS256' algorithm // Create a JWT token signed using the 'HS256' algorithm
String newJwtCookie = Jwt.issuer("https://example.com/issuer").upn(name).groups(users.roles).sign(); String newJwtCookie = Jwt.issuer("https://example.com/issuer").upn(name).groups(users.roles).claim(Claims.kid, users.id.toString()).sign();
// or create a JWT token encrypted using the 'A256KW' algorithm // or create a JWT token encrypted using the 'A256KW' algorithm
// Jwt.upn("alice").encryptWithSecret(secret); // Jwt.upn("alice").encryptWithSecret(secret);
return Response.status(Response.Status.CREATED).cookie(new NewCookie("jwt", newJwtCookie)).build(); return Response.status(Response.Status.CREATED).cookie(new NewCookie("jwt", newJwtCookie)).build();