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
Exceptionif 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
Exceptionif 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
Exceptionif error occurs getting and showing Web Session info
Β
- π Minimum Java Version:
21 - π Minimum Spring Boot Version:
3.3.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.5.0</version> </dependency>
implementation("best.skn:skn-spring-security:1.5.0")
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:5000(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:5000/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:5000/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: - / - /api/mail/**
Β
- π©βπ¨
Prodipta Das Logno& π§ββοΈAtoshi Sarker Prithula: The two most special ladies of my life. My best wishes will always be with you two. May you two always be happy. - π―
My Parents: The greatest treasures of my life ever.
Β
Copyright (C) 2024 SKN Shukhan
Licensed under the Apache License, Version 2.0