use of io.micronaut.session.Session in project micronaut-security by micronaut-projects.
the class SessionStatePersistence method persistState.
@Override
public void persistState(HttpRequest<?> request, MutableHttpResponse response, State state) {
Session session = SessionForRequest.find(request).orElseGet(() -> SessionForRequest.create(sessionStore, request));
session.put(SESSION_KEY, state);
}
use of io.micronaut.session.Session in project micronaut-security by micronaut-projects.
the class SessionLogoutHandler method removeAuthenticationFromSession.
private void removeAuthenticationFromSession(HttpRequest<?> request) {
MutableConvertibleValues<Object> attrs = request.getAttributes();
Optional<Session> existing = attrs.get(HttpSessionFilter.SESSION_ATTRIBUTE, Session.class);
if (existing.isPresent()) {
Session session = existing.get();
session.remove(SecurityFilter.AUTHENTICATION);
}
}
use of io.micronaut.session.Session in project micronaut-security by micronaut-projects.
the class SessionNoncePersistence method persistNonce.
@Override
public void persistNonce(HttpRequest<?> request, MutableHttpResponse response, String state) {
Session session = SessionForRequest.find(request).orElseGet(() -> SessionForRequest.create(sessionStore, request));
session.put(SESSION_KEY, state);
}
use of io.micronaut.session.Session in project micronaut-security by micronaut-projects.
the class SessionAuthenticationFetcher method fetchAuthentication.
@Override
public Publisher<Authentication> fetchAuthentication(HttpRequest<?> request) {
return Mono.<Authentication>create(emitter -> {
Optional<Session> opt = request.getAttributes().get(HttpSessionFilter.SESSION_ATTRIBUTE, Session.class);
if (opt.isPresent()) {
Session session = opt.get();
Optional<Authentication> authentication = session.get(SecurityFilter.AUTHENTICATION, Authentication.class);
authentication.ifPresent(emitter::success);
}
emitter.success();
});
}
use of io.micronaut.session.Session in project micronaut-security by micronaut-projects.
the class SessionLoginHandler method saveAuthenticationInSession.
private void saveAuthenticationInSession(Authentication authentication, HttpRequest<?> request) {
Session session = SessionForRequest.find(request).orElseGet(() -> SessionForRequest.create(sessionStore, request));
session.put(SecurityFilter.AUTHENTICATION, authentication);
}
Aggregations