add expire

This commit is contained in:
Valentin CZERYBA 2022-05-15 11:33:27 +02:00
parent b91b0dd734
commit 88d93ab8e8

View File

@ -1,6 +1,7 @@
package com.covas.Resources;
import java.nio.charset.StandardCharsets;
import java.time.Duration;
import java.util.Arrays;
import java.util.HashSet;
@ -58,7 +59,7 @@ public class TokenRessource {
return Response.status(Response.Status.FORBIDDEN).build();
}
// Create a JWT token signed using the 'HS256' algorithm
String newJwtCookie = Jwt.issuer("https://example.com/issuer").upn(name).groups(users.roles).claim(Claims.kid, users.id.toString()).sign();
String newJwtCookie = Jwt.issuer("https://example.com/issuer").upn(name).groups(users.roles).claim(Claims.kid, users.id.toString()).expiresIn(Duration.ofMinutes(1)).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();