Java
Β
Β
I made this library so that I can use it in most of my spring boot reactive projects without writing the same codes over and over again
The main API Classes of this library are CsrfService
, PrincipalService
& SessionService
, each of which holds a method for GET request
Β
- It needs to be instantiated first
- It must be used in controller GET requests
- It has 1 method to get CSRF Token if CSRF is enabled in Spring Security
- This method throws
Exception
if error occurs getting and showing CSRF token
- It needs to be instantiated first
- It must be used in controller GET requests
- It has 1 method to get Principal information i.e. the info of the authenticated users
- This method throws
Exception
if error occurs getting and showing Principal info
- It needs to be instantiated first
- It must be used in controller GET requests
- It has 1 method to get Web Session information
- This method throws
Exception
if error occurs getting and showing Web Session info
Β
- π Minimum Java Version:
21
- π Minimum Maven Version:
3.9.6
- π Minimum Spring Boot Version:
3.2.5
- π Spring Web Flux (Reactive Spring Boot)
- π Spring Security
- π Spring Session
- π Spring OAuth2 Client
Β
<dependency> <groupId>best.skn</groupId> <artifactId>skn-spring-security</artifactId> <version>1.2.1</version> </dependency>
mvn install
import best.skn.security.configurations.*; @Configuration @Import( { CsrfConfiguration.class, PrincipalConfiguration.class, SessionConfiguration.class } ) public class SecurityInfoConfiguration {}
import best.skn.security.services.CsrfService;
import best.skn.security.services.PrincipalService;
import best.skn.security.services.SessionService;
(1) CORS Configuration: When setting your CORS allowed origins, you have to give a list of String as a parameter in Spring Security, but with this library you can externalize it
import best.skn.security.properties.CorsSourceProperty; @Configuration @EnableConfigurationProperties(CorsSourceProperty.class) public class CorsSourceConfiguration() { @Autowired private CorsSourceProperty corsSourceProperty; // your configuration here. The class name is arbitary. }skn: security: cors: origins: - http://localhost:3000 - http://localhost:5173(2) Login Configuration: When setting your custom login url, you have to give a String as a parameter in Spring Security, but with this library you can externalize it
import best.skn.security.properties.LoginProperty; @Configuration @EnableConfigurationProperties(LoginProperty.class) public class LoginConfiguration() { @Autowired private LoginProperty loginProperty; // your configuration here. The class name is arbitary. }skn: security: login: url: http://localhost:5173/api/auth/login(3) OAuth2 Configuration: When setting your custom successful login redirection url for OAuth2, you have to give a String as a parameter in Spring Security, but with this library you can externalize it
import best.skn.security.properties.OAuth2Property; @Configuration @EnableConfigurationProperties(OAuth2Property.class) public class OAuth2Configuration() { @Autowired private OAuth2Property oAuth2Property; // your configuration here. The class name is arbitary. }skn: security: oauth2: client: success: redirect: http://localhost:5173/api/auth/status(4) Security Configuration: When setting your authenticated exchanges, you have to give a list of String as a parameter in Spring Security, but with this library you can externalize it
import best.skn.security.properties.SecurityProperty; @Configuration @EnableConfigurationProperties(SecurityProperty.class) public class SecurityConfiguration() { @Autowired private SecurityProperty securityProperty; // your configuration here. The class name is arbitary. }skn: security: authorize: exchanges: - / - /skn/** - /api/auth/** - /api/mail/**
For instructions for Gradle
& others: Visit Maven Central
Β
- π©βπ¨
Prodipta Das Logno
& π§ββοΈAtoshi Sarker Prithula
: The two most special ladies of my life. I can't thank them enough for always treasuring me a lot. I am lucky that I met with these two amazing ladies. They have two special places in my heart and no other girl can ever replace them. - π―
My Parents
: The greatest treasures of my life ever.