add expire
This commit is contained in:
parent
b91b0dd734
commit
88d93ab8e8
@ -1,6 +1,7 @@
|
|||||||
package com.covas.Resources;
|
package com.covas.Resources;
|
||||||
|
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.time.Duration;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
|
||||||
@ -58,7 +59,7 @@ public class TokenRessource {
|
|||||||
return Response.status(Response.Status.FORBIDDEN).build();
|
return Response.status(Response.Status.FORBIDDEN).build();
|
||||||
}
|
}
|
||||||
// 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).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
|
// 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();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user