From 39ad985eae13b64816805402410597e7956af1ac Mon Sep 17 00:00:00 2001 From: Valentin CZERYBA Date: Fri, 13 May 2022 21:01:31 +0200 Subject: [PATCH] Add claims kid --- src/main/java/com/covas/Resources/TokenRessource.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/covas/Resources/TokenRessource.java b/src/main/java/com/covas/Resources/TokenRessource.java index 2b19a1f..b5a1552 100644 --- a/src/main/java/com/covas/Resources/TokenRessource.java +++ b/src/main/java/com/covas/Resources/TokenRessource.java @@ -21,7 +21,7 @@ import io.smallrye.jwt.auth.principal.JWTParser; import io.smallrye.jwt.auth.principal.ParseException; import io.smallrye.jwt.build.Jwt; - +import org.eclipse.microprofile.jwt.Claims; import org.eclipse.microprofile.jwt.JsonWebToken; import org.jboss.logging.Logger; import org.jboss.resteasy.annotations.jaxrs.HeaderParam; @@ -57,7 +57,7 @@ public class TokenRessource { if(password.equals(users.password)){ // 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 // Jwt.upn("alice").encryptWithSecret(secret); return Response.status(Response.Status.CREATED).cookie(new NewCookie("jwt", newJwtCookie)).build();