package org.raddatz.familienarchiv.auth;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.session.jdbc.JdbcIndexedSessionRepository;

@Configuration
class SessionRevocationConfig {

    @Bean
    SessionRevocationPort sessionRevocationPort(
            @Autowired(required = false) JdbcIndexedSessionRepository sessionRepository) {
        if (sessionRepository != null) {
            return new JdbcSessionRevocationAdapter(sessionRepository);
        }
        return new NoOpSessionRevocationAdapter();
    }
}
