use of io.micronaut.security.token.jwt.render.AccessRefreshToken in project micronaut-graphql by micronaut-projects.
the class LoginDataFetcher method accessTokenCookie.
private Optional<Cookie> accessTokenCookie(Authentication authentication, HttpRequest<?> request) {
Optional<AccessRefreshToken> accessRefreshTokenOptional = accessRefreshTokenGenerator.generate(authentication);
if (accessRefreshTokenOptional.isPresent()) {
Cookie cookie = Cookie.of(cookieConfiguration.getCookieName(), accessRefreshTokenOptional.get().getAccessToken());
cookie.configure(cookieConfiguration, request.isSecure());
Optional<TemporalAmount> cookieMaxAge = cookieConfiguration.getCookieMaxAge();
if (cookieMaxAge.isPresent()) {
cookie.maxAge(cookieMaxAge.get());
} else {
cookie.maxAge(accessTokenConfiguration.getExpiration());
}
return Optional.of(cookie);
}
return Optional.empty();
}
Aggregations