├── .gitignore ├── .mvn └── wrapper │ ├── maven-wrapper.jar │ └── maven-wrapper.properties ├── Dockerfile ├── README.md ├── docker-compose.yml ├── mvnw ├── mvnw.cmd ├── pom.xml ├── postman_collection └── Spring Security Example.postman_collection.json ├── screenshots ├── spring_1.PNG ├── spring_10.PNG ├── spring_11.PNG ├── spring_12.PNG ├── spring_13.PNG ├── spring_14.PNG ├── spring_15.PNG ├── spring_16.PNG ├── spring_2.PNG ├── spring_3.PNG ├── spring_4.PNG ├── spring_5.PNG ├── spring_6.PNG ├── spring_7.PNG ├── spring_8.PNG ├── spring_9.PNG └── spring_boot_security_example_jwt_implementation.png └── src ├── main ├── java │ └── com │ │ └── springboot │ │ └── springbootsecurity │ │ ├── SpringBootSecurityApplication.java │ │ ├── admin │ │ ├── controller │ │ │ └── AdminAuthController.java │ │ ├── exception │ │ │ ├── AdminAlreadyExistException.java │ │ │ └── AdminNotFoundException.java │ │ ├── model │ │ │ ├── Admin.java │ │ │ ├── dto │ │ │ │ └── request │ │ │ │ │ └── AdminRegisterRequest.java │ │ │ ├── entity │ │ │ │ └── AdminEntity.java │ │ │ └── mapper │ │ │ │ ├── AdminEntityToAdminMapper.java │ │ │ │ ├── AdminRegisterRequestToAdminEntityMapper.java │ │ │ │ └── AdminToAdminEntityMapper.java │ │ ├── repository │ │ │ └── AdminRepository.java │ │ └── service │ │ │ ├── AdminLoginService.java │ │ │ ├── AdminLogoutService.java │ │ │ ├── AdminRefreshTokenService.java │ │ │ ├── AdminRegisterService.java │ │ │ └── impl │ │ │ ├── AdminLoginServiceImpl.java │ │ │ ├── AdminLogoutServiceImpl.java │ │ │ ├── AdminRefreshTokenServiceImpl.java │ │ │ └── AdminRegisterServiceImpl.java │ │ ├── auth │ │ ├── config │ │ │ ├── SecurityConfig.java │ │ │ └── TokenConfigurationParameter.java │ │ ├── exception │ │ │ ├── PasswordNotValidException.java │ │ │ ├── TokenAlreadyInvalidatedException.java │ │ │ └── UserStatusNotValidException.java │ │ ├── filter │ │ │ └── CustomBearerTokenAuthenticationFilter.java │ │ ├── model │ │ │ ├── Identity.java │ │ │ ├── Token.java │ │ │ ├── dto │ │ │ │ ├── request │ │ │ │ │ ├── LoginRequest.java │ │ │ │ │ ├── TokenInvalidateRequest.java │ │ │ │ │ └── TokenRefreshRequest.java │ │ │ │ └── response │ │ │ │ │ └── TokenResponse.java │ │ │ ├── entity │ │ │ │ └── InvalidTokenEntity.java │ │ │ ├── enums │ │ │ │ ├── ConfigurationParameter.java │ │ │ │ ├── TokenClaims.java │ │ │ │ ├── TokenType.java │ │ │ │ ├── UserStatus.java │ │ │ │ └── UserType.java │ │ │ └── mapper │ │ │ │ └── TokenToTokenResponseMapper.java │ │ ├── repository │ │ │ └── InvalidTokenRepository.java │ │ ├── security │ │ │ └── CustomAuthenticationEntryPoint.java │ │ ├── service │ │ │ ├── InvalidTokenService.java │ │ │ ├── TokenService.java │ │ │ └── impl │ │ │ │ ├── InvalidTokenServiceImpl.java │ │ │ │ └── TokenServiceImpl.java │ │ └── utils │ │ │ └── KeyConverter.java │ │ ├── common │ │ ├── exception │ │ │ └── GlobalExceptionHandler.java │ │ └── model │ │ │ ├── BaseDomainModel.java │ │ │ ├── CustomError.java │ │ │ ├── CustomPage.java │ │ │ ├── CustomPaging.java │ │ │ ├── dto │ │ │ ├── request │ │ │ │ └── CustomPagingRequest.java │ │ │ └── response │ │ │ │ ├── CustomPagingResponse.java │ │ │ │ └── CustomResponse.java │ │ │ ├── entity │ │ │ └── BaseEntity.java │ │ │ └── mapper │ │ │ └── BaseMapper.java │ │ ├── product │ │ ├── controller │ │ │ └── ProductController.java │ │ ├── exception │ │ │ ├── ProductAlreadyExistException.java │ │ │ └── ProductNotFoundException.java │ │ ├── model │ │ │ ├── Product.java │ │ │ ├── dto │ │ │ │ ├── request │ │ │ │ │ ├── ProductCreateRequest.java │ │ │ │ │ ├── ProductPagingRequest.java │ │ │ │ │ └── ProductUpdateRequest.java │ │ │ │ └── response │ │ │ │ │ └── ProductResponse.java │ │ │ ├── entity │ │ │ │ └── ProductEntity.java │ │ │ └── mapper │ │ │ │ ├── CustomPageToCustomPagingResponseMapper.java │ │ │ │ ├── ListProductEntityToListProductMapper.java │ │ │ │ ├── ProductCreateRequestToProductEntityMapper.java │ │ │ │ ├── ProductEntityToProductMapper.java │ │ │ │ ├── ProductToProductEntityMapper.java │ │ │ │ ├── ProductToProductResponseMapper.java │ │ │ │ └── ProductUpdateRequestToProductEntityMapper.java │ │ ├── repository │ │ │ └── ProductRepository.java │ │ └── service │ │ │ ├── ProductCreateService.java │ │ │ ├── ProductDeleteService.java │ │ │ ├── ProductReadService.java │ │ │ ├── ProductUpdateService.java │ │ │ └── impl │ │ │ ├── ProductCreateServiceImpl.java │ │ │ ├── ProductDeleteServiceImpl.java │ │ │ ├── ProductReadServiceImpl.java │ │ │ └── ProductUpdateServiceImpl.java │ │ └── user │ │ ├── controller │ │ └── UserAuthController.java │ │ ├── exception │ │ ├── UserAlreadyExistException.java │ │ └── UserNotFoundException.java │ │ ├── model │ │ ├── User.java │ │ ├── dto │ │ │ └── request │ │ │ │ └── UserRegisterRequest.java │ │ ├── entity │ │ │ └── UserEntity.java │ │ └── mapper │ │ │ ├── UserEntityToUserMapper.java │ │ │ ├── UserRegisterRequestToUserEntityMapper.java │ │ │ └── UserToUserEntityMapper.java │ │ ├── repository │ │ └── UserRepository.java │ │ └── service │ │ ├── UserLoginService.java │ │ ├── UserLogoutService.java │ │ ├── UserRefreshTokenService.java │ │ ├── UserRegisterService.java │ │ └── impl │ │ ├── UserLoginServiceImpl.java │ │ ├── UserLogoutServiceImpl.java │ │ ├── UserRefreshTokenServiceImpl.java │ │ └── UserRegisterServiceImpl.java └── resources │ └── application.yaml └── test └── java └── com └── springboot └── springbootsecurity ├── SpringBootSecurityApplicationTests.java ├── admin ├── controller │ └── AdminAuthControllerTest.java └── service │ └── impl │ ├── AdminLoginServiceImplTest.java │ ├── AdminLogoutServiceImplTest.java │ ├── AdminRefreshTokenServiceImplTest.java │ └── AdminRegisterServiceImplTest.java ├── base ├── AbstractBaseServiceTest.java ├── AbstractRestControllerTest.java └── AbstractTestContainerConfiguration.java ├── builder ├── AdminEntityBuilder.java ├── BaseBuilder.java ├── TokenBuilder.java └── UserEntityBuilder.java ├── product ├── controller │ └── ProductControllerTest.java └── service │ └── impl │ ├── ProductCreateServiceImplTest.java │ ├── ProductDeleteServiceImplTest.java │ ├── ProductReadServiceImplTest.java │ └── ProductUpdateServiceImplTest.java └── user ├── controller └── UserAuthControllerTest.java └── service └── impl ├── UserLoginServiceImplTest.java ├── UserLogoutServiceImplTest.java ├── UserRefreshTokenServiceImplTest.java └── UserRegisterServiceImplTest.java /.gitignore: -------------------------------------------------------------------------------- 1 | HELP.md 2 | target/ 3 | !.mvn/wrapper/maven-wrapper.jar 4 | !**/src/main/**/target/ 5 | !**/src/test/**/target/ 6 | 7 | ### STS ### 8 | .apt_generated 9 | .classpath 10 | .factorypath 11 | .project 12 | .settings 13 | .springBeans 14 | .sts4-cache 15 | 16 | ### IntelliJ IDEA ### 17 | .idea 18 | *.iws 19 | *.iml 20 | *.ipr 21 | 22 | ### NetBeans ### 23 | /nbproject/private/ 24 | /nbbuild/ 25 | /dist/ 26 | /nbdist/ 27 | /.nb-gradle/ 28 | build/ 29 | !**/src/main/**/build/ 30 | !**/src/test/**/build/ 31 | 32 | ### VS Code ### 33 | .vscode/ 34 | 35 | ### Environment file 36 | .env 37 | -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Rapter1990/springbootsecurity/2ec9bea644a6f2885962e25f5362b5b3e465e955/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.5/apache-maven-3.9.5-bin.zip 2 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 3 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Stage 1: Build stage 2 | FROM maven:3.8.4-openjdk-17-slim AS build 3 | 4 | # Copy Maven files for dependency resolution 5 | COPY pom.xml ./ 6 | COPY .mvn .mvn 7 | 8 | # Copy application source code 9 | COPY src src 10 | 11 | # Build the project and create the executable JAR 12 | RUN mvn clean install -DskipTests 13 | 14 | # Stage 2: Run stage 15 | FROM openjdk:17-jdk-slim 16 | 17 | # Set working springbootsecurity 18 | WORKDIR springbootsecurity 19 | 20 | # Copy the JAR file from the build stage 21 | COPY --from=build target/*.jar springbootsecurityexample.jar 22 | 23 | # Expose port 1223 24 | EXPOSE 1223 25 | 26 | # Set the entrypoint command for running the application 27 | ENTRYPOINT ["java", "-jar", "springbootsecurityexample.jar"] -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Spring Boot with Spring Security through JWT Implementation 2 | 3 |
4 |
5 |
Method | 23 |Url | 24 |Description | 25 |Request Body | 26 |Header | 27 |Valid Path Variable | 28 |No Path Variable | 29 |
---|---|---|---|---|---|---|
POST | 32 |/api/v1/authentication/admin/register | 33 |Admin Register | 34 |AdminRegisterRequest | 35 |36 | | 37 | | 38 | |
POST | 41 |/api/v1/authentication/admin/login | 42 |Admin Login | 43 |LoginRequest | 44 |45 | | 46 | | 47 | |
POST | 50 |/api/v1/authentication/admin/refreshtoken | 51 |Admin Refresh Token | 52 |TokenRefreshRequest | 53 |54 | | 55 | | 56 | |
POST | 59 |/api/v1/authentication/admin/logout | 60 |Admin Logout | 61 |TokenInvalidateRequest | 62 |63 | | 64 | | 65 | |
POST | 68 |/api/v1/authentication/user/register | 69 |User Register | 70 |UserRegisterRequest | 71 |72 | | 73 | | 74 | |
POST | 77 |/api/v1/authentication/user/login | 78 |User Login | 79 |LoginRequest | 80 |81 | | 82 | | 83 | |
POST | 86 |/api/v1/authentication/user/refreshtoken | 87 |User Refresh Token | 88 |TokenRefreshRequest | 89 |90 | | 91 | | 92 | |
POST | 95 |/api/v1/authentication/user/logout | 96 |User Logout | 97 |TokenInvalidateRequest | 98 |99 | | 100 | | 101 | |
POST | 104 |/api/v1/products | 105 |Create Product | 106 |ProductCreateRequest | 107 |108 | | 109 | | 110 | |
GET | 113 |/api/v1/products/{productId} | 114 |Get Product By Id | 115 |116 | | 117 | | ProductId | 118 |119 | |
GET | 122 |/api/v1/products | 123 |Get Products | 124 |ProductPagingRequest | 125 |126 | | 127 | | 128 | |
PUT | 131 |/api/v1/products/{productId} | 132 |Update Product By Id | 133 |ProductUpdateRequest | 134 |135 | | ProductId | 136 |137 | |
DELETE | 140 |/api/v1/products/{productId} | 141 |Delete Product By Id | 142 |143 | | 144 | | ProductId | 145 |146 | |
Figure 1
211 |Figure 2
213 |Figure 3
215 |Figure 4
217 |Figure 5
219 |Figure 6
221 |Figure 7
223 |Figure 8
225 |Figure 9
227 |Figure 10
229 |Figure 11
231 |Figure 12
233 |Figure 13
235 |Figure 14
237 |Figure 15
239 |Figure 16
241 |