add maxages for cookie
This commit is contained in:
parent
37205291ad
commit
d1c84d5261
@ -10,10 +10,13 @@ import javax.ws.rs.Path;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
import javax.ws.rs.core.NewCookie;
|
||||
import javax.ws.rs.core.Cookie;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
import com.covas.Classes.Hash;
|
||||
import com.covas.Entity.UsersEntity;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.DurationDeserializer;
|
||||
|
||||
import io.smallrye.jwt.auth.principal.JWTParser;
|
||||
import io.smallrye.jwt.auth.principal.ParseException;
|
||||
@ -64,13 +67,15 @@ public class TokenRessource {
|
||||
// or create a JWT token encrypted using the 'A256KW' algorithm
|
||||
// Jwt.upn("alice").encryptWithSecret(secret);
|
||||
String nameEncoded = Base64.toBase64String(name.getBytes(StandardCharsets.UTF_8));
|
||||
return Response.status(Response.Status.CREATED).cookie(new NewCookie("jwt", newJwtCookie), new NewCookie("user", nameEncoded)).build();
|
||||
return Response.status(Response.Status.CREATED).cookie(new NewCookie(new Cookie("jwt", newJwtCookie), "Token JWT", 60, false), new NewCookie(new Cookie("user", nameEncoded), "Username", 60, false)).build();
|
||||
}
|
||||
// All mp.jwt and smallrye.jwt properties are still effective, only the verification key is customized.
|
||||
LOGGER.info(jwtCookie);
|
||||
try {
|
||||
jwt = parser.parse(jwtCookie);
|
||||
}
|
||||
catch(ParseException p){
|
||||
LOGGER.info(p);
|
||||
return Response.status(Response.Status.NOT_ACCEPTABLE).build();
|
||||
}
|
||||
// or jwt = parser.decrypt(jwtCookie, secret);
|
||||
|
Loading…
x
Reference in New Issue
Block a user