Created
February 8, 2023 13:49
-
-
Save sandeeppagatur/8ed669abdfef0eb21f7791c61fee7a05 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-data-redis</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.session</groupId> | |
<artifactId>spring-session-data-redis</artifactId> | |
</dependency> | |
//these two dependencies will scan the properties for redis and creates connection auto | |
spring.session.store-type=redis | |
server.servlet.session.timeout=#in seconds | |
spring.redis.host=localhost | |
spring.redis.port=6379 | |
@Configuration | |
@EnableRedisIndexedHttpSession | |
public class SpringSecurityConfig { | |
//This is required in SecurityConfig file to register - context repository implementation is changed in springboot3 | |
@Bean | |
public SecurityContextRepository securityContextRepository() { | |
return new DelegatingSecurityContextRepository( | |
new RequestAttributeSecurityContextRepository(), | |
new HttpSessionSecurityContextRepository() | |
); | |
} | |
@Bean | |
public RedisConnectionFactory connectionFactory() { | |
return new LettuceConnectionFactory(); | |
}// no need to set host and port - springboot3 by default recognises from the properties file - store type,host,port,timeout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment