From 808d2b253b2d0ced5e07f0c52b6c92d4d2119666 Mon Sep 17 00:00:00 2001 From: Rohit Date: Fri, 30 Aug 2024 21:27:58 +0530 Subject: [PATCH] feature/swagger-added --- .../ElasticClientConfiguration.java | 9 - .../configuration/SecurityConfiguration.java | 1 - .../controller/AuthenticationController.java | 225 ++++++++++++++++++ .../provider/controller/UserController.java | 108 ++++++++- .../OauthUserToUserAuthTransformer.java | 1 - 5 files changed, 329 insertions(+), 15 deletions(-) diff --git a/src/main/java/com/bloggios/auth/provider/configuration/ElasticClientConfiguration.java b/src/main/java/com/bloggios/auth/provider/configuration/ElasticClientConfiguration.java index 0a18387..2e3498c 100644 --- a/src/main/java/com/bloggios/auth/provider/configuration/ElasticClientConfiguration.java +++ b/src/main/java/com/bloggios/auth/provider/configuration/ElasticClientConfiguration.java @@ -30,8 +30,6 @@ import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.springframework.core.env.Environment; -import org.springframework.core.io.ClassPathResource; -import org.springframework.core.io.Resource; import org.springframework.data.elasticsearch.client.ClientConfiguration; import org.springframework.data.elasticsearch.client.RestClients; import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration; @@ -40,13 +38,6 @@ import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories; import org.springframework.http.HttpHeaders; -import javax.net.ssl.SSLContext; -import javax.net.ssl.TrustManagerFactory; -import java.io.InputStream; -import java.security.KeyStore; -import java.security.cert.Certificate; -import java.security.cert.CertificateFactory; - /** * Owner - Rohit Parihar * Author - rohit diff --git a/src/main/java/com/bloggios/auth/provider/configuration/SecurityConfiguration.java b/src/main/java/com/bloggios/auth/provider/configuration/SecurityConfiguration.java index 10a3942..8f6695a 100644 --- a/src/main/java/com/bloggios/auth/provider/configuration/SecurityConfiguration.java +++ b/src/main/java/com/bloggios/auth/provider/configuration/SecurityConfiguration.java @@ -39,7 +39,6 @@ import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer; import org.springframework.security.config.http.SessionCreationPolicy; -import org.springframework.security.core.userdetails.UserDetailsService; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.security.web.SecurityFilterChain; diff --git a/src/main/java/com/bloggios/auth/provider/controller/AuthenticationController.java b/src/main/java/com/bloggios/auth/provider/controller/AuthenticationController.java index b2b55b9..94f91b2 100644 --- a/src/main/java/com/bloggios/auth/provider/controller/AuthenticationController.java +++ b/src/main/java/com/bloggios/auth/provider/controller/AuthenticationController.java @@ -31,9 +31,14 @@ import com.bloggios.auth.provider.payload.request.GoogleLoginRequest; import com.bloggios.auth.provider.payload.request.RegisterRequest; import com.bloggios.auth.provider.payload.response.AuthResponse; +import com.bloggios.auth.provider.payload.response.ExceptionResponse; import com.bloggios.auth.provider.payload.response.ModuleResponse; import com.bloggios.auth.provider.service.AuthenticationService; import com.bloggios.auth.provider.utils.AsyncUtils; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; import lombok.extern.slf4j.Slf4j; import org.springframework.http.HttpHeaders; import org.springframework.http.ResponseEntity; @@ -66,11 +71,45 @@ public AuthenticationController( } @PostMapping(EndpointConstants.AuthenticationController.REGISTER_PATH) + @Operation( + + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ModuleResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity registerUser(@RequestBody RegisterRequest registerRequest, HttpServletRequest request) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(authenticationService.registerUser(registerRequest, request))); } @PostMapping(EndpointConstants.AuthenticationController.LOGIN_PATH) + @Operation( + + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = AuthResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity authenticate(@RequestBody AuthenticationRequest authenticationRequest, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { CompletableFuture authenticate = authenticationService.authenticate(authenticationRequest, httpServletRequest, httpServletResponse); AuthResponse asyncResult = AsyncUtils.getAsyncResult(authenticate); @@ -82,16 +121,67 @@ public ResponseEntity authenticate(@RequestBody AuthenticationRequ } @GetMapping(EndpointConstants.AuthenticationController.VERIFY_OTP) + @Operation( + + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ModuleResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity verifyOtp(@RequestHeader("otp") String otp, @RequestParam("userId") String userId) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(authenticationService.verifyOtp(otp, userId))); } @GetMapping(EndpointConstants.AuthenticationController.RESEND_OTP) + @Operation( + + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ModuleResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity resendOtp(@RequestParam(value = "userId") String userId) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(authenticationService.resendOtp(userId))); } @GetMapping(EndpointConstants.AuthenticationController.REFRESH_TOKEN) + @Operation( + + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = AuthResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity refreshToken(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { AuthResponse response = AsyncUtils.getAsyncResult(authenticationService.refreshToken(httpServletRequest, httpServletResponse)); return ResponseEntity @@ -102,11 +192,45 @@ public ResponseEntity refreshToken(HttpServletRequest httpServletR } @PostMapping(EndpointConstants.AuthenticationController.OTP_USER_ID) + @Operation( + + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ModuleResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity otpRedirectUserId(@RequestBody AuthenticationRequest authenticationRequest) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(authenticationService.otpRedirectUserId(authenticationRequest))); } @GetMapping(EndpointConstants.AuthenticationController.LOGOUT) + @Operation( + + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = AuthResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity logoutUser(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { AuthResponse authResponse = AsyncUtils.getAsyncResult(authenticationService.logoutUser(httpServletRequest, httpServletResponse)); return ResponseEntity @@ -116,6 +240,23 @@ public ResponseEntity logoutUser(HttpServletRequest httpServletReq } @GetMapping(EndpointConstants.AuthenticationController.USER_IP) + @Operation( + + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = String.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity userIp(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) { String clientIp = httpServletRequest.getHeader("X-Forwarded-For"); if (clientIp != null && clientIp.contains(",")) { @@ -125,6 +266,23 @@ public ResponseEntity userIp(HttpServletRequest httpServletRequest, Http } @GetMapping(EndpointConstants.AuthenticationController.REFRESH_TOKEN_SOCIAL) + @Operation( + + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = AuthResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity refreshTokenSocial(@RequestParam String token, HttpServletResponse httpServletResponse, HttpServletRequest httpServletRequest) { AuthResponse response = AsyncUtils.getAsyncResult(authenticationService.refreshTokenSocial(token, httpServletResponse, httpServletRequest)); return ResponseEntity @@ -135,21 +293,88 @@ public ResponseEntity refreshTokenSocial(@RequestParam String toke } @GetMapping(EndpointConstants.AuthenticationController.FORGET_PASSWORD_OTP_PATH) + @Operation( + + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ModuleResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity forgetPasswordOtp(@RequestParam(name = "email") String email) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(authenticationService.forgetPasswordOtp(email))); } @PostMapping(EndpointConstants.AuthenticationController.FORGET_PASSWORD_PATH) + @Operation( + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ModuleResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity forgetPassword(@RequestBody ForgetPasswordRequest forgetPasswordRequest) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(authenticationService.forgetPassword(forgetPasswordRequest))); } @GetMapping(EndpointConstants.AuthenticationController.REMOTE_ADDRESS) + @Operation( + + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = RemoteAddressResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity remoteAddress(HttpServletRequest request) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(authenticationService.remoteAddress(request))); } @PostMapping(EndpointConstants.OAuthController.GOOGLE_LOGIN) + @Operation( + + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = AuthResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + } + ) public ResponseEntity loginGoogle(@RequestBody GoogleLoginRequest googleLoginRequest, HttpServletRequest httpServletRequest) { CompletableFuture authenticate = authenticationService.loginGoogle(googleLoginRequest, httpServletRequest); AuthResponse asyncResult = AsyncUtils.getAsyncResult(authenticate); diff --git a/src/main/java/com/bloggios/auth/provider/controller/UserController.java b/src/main/java/com/bloggios/auth/provider/controller/UserController.java index 145f8fa..1c23ec3 100644 --- a/src/main/java/com/bloggios/auth/provider/controller/UserController.java +++ b/src/main/java/com/bloggios/auth/provider/controller/UserController.java @@ -27,11 +27,17 @@ import com.bloggios.auth.provider.constants.EndpointConstants; import com.bloggios.auth.provider.payload.request.AssignRoleRequest; import com.bloggios.auth.provider.payload.request.ChangePasswordRequest; +import com.bloggios.auth.provider.payload.response.ExceptionResponse; import com.bloggios.auth.provider.payload.response.ModuleResponse; import com.bloggios.auth.provider.payload.response.UserAuthResponse; import com.bloggios.auth.provider.payload.response.UserProfileResponse; import com.bloggios.auth.provider.service.UserService; import com.bloggios.auth.provider.utils.AsyncUtils; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.media.Content; +import io.swagger.v3.oas.annotations.media.Schema; +import io.swagger.v3.oas.annotations.responses.ApiResponse; +import io.swagger.v3.oas.annotations.security.SecurityRequirement; import org.springframework.http.ResponseEntity; import org.springframework.security.core.annotation.AuthenticationPrincipal; import org.springframework.web.bind.annotation.*; @@ -58,25 +64,119 @@ public UserController( } @GetMapping + @Operation( + requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( + required = false + ), + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = UserAuthResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + }, + security = { + @SecurityRequirement( + name = "bearerAuth" + ) + } + ) public ResponseEntity getLoggedInUser(@AuthenticationPrincipal UserPrincipal userPrincipal) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(userService.getLoggedInUser(userPrincipal))); } @PostMapping(EndpointConstants.UserController.CHANGE_PASSWORD) + @Operation( + requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( + required = false + ), + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ModuleResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + }, + security = { + @SecurityRequirement( + name = "bearerAuth" + ) + } + ) public ResponseEntity changePassword(@RequestBody ChangePasswordRequest changePasswordRequest, @AuthenticationPrincipal UserPrincipal userPrincipal) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(userService.changePassword(changePasswordRequest, userPrincipal))); } @PostMapping(EndpointConstants.UserController.ASSIGN_ROLES) + @Operation( + requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( + required = false + ), + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = ModuleResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + }, + security = { + @SecurityRequirement( + name = "bearerAuth" + ) + } + ) public ResponseEntity assignRole(@RequestBody AssignRoleRequest assignRoleRequest, @AuthenticationPrincipal UserPrincipal authenticatedUser) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(userService.assignRoles(assignRoleRequest, authenticatedUser))); } - /** - * Internal API - * To be called through Feign Client - */ + @GetMapping(EndpointConstants.UserController.GET_USER_PROFILE_RESPONSE) + @Operation( + summary = "This API is developed for Inter Communication between Microservices", + requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody( + required = false + ), + responses = { + @ApiResponse(description = "SUCCESS", responseCode = "200", content = @Content( + mediaType = "application/json", schema = @Schema(implementation = UserProfileResponse.class) + )), + @ApiResponse(description = "No Content", responseCode = "401", content = { + @Content(schema = @Schema(implementation = Void.class)) + }), + @ApiResponse(description = "FORBIDDEN", responseCode = "403", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = String.class)) + }), + @ApiResponse(description = "BAD REQUEST", responseCode = "400", content = { + @Content(mediaType = "application/json", schema = @Schema(implementation = ExceptionResponse.class)) + }) + }, + security = { + @SecurityRequirement( + name = "bearerAuth" + ) + } + ) public ResponseEntity getUserProfileResponse(@AuthenticationPrincipal UserPrincipal userPrincipal) { return ResponseEntity.ok(AsyncUtils.getAsyncResult(userService.getUserProfileResponse(userPrincipal))); } diff --git a/src/main/java/com/bloggios/auth/provider/transformer/implementation/OauthUserToUserAuthTransformer.java b/src/main/java/com/bloggios/auth/provider/transformer/implementation/OauthUserToUserAuthTransformer.java index eac355d..94d8863 100644 --- a/src/main/java/com/bloggios/auth/provider/transformer/implementation/OauthUserToUserAuthTransformer.java +++ b/src/main/java/com/bloggios/auth/provider/transformer/implementation/OauthUserToUserAuthTransformer.java @@ -33,7 +33,6 @@ import com.bloggios.auth.provider.utils.UsernameGenerator; import lombok.RequiredArgsConstructor; import org.springframework.core.env.Environment; -import org.springframework.security.crypto.password.PasswordEncoder; import org.springframework.stereotype.Component; import javax.servlet.http.HttpServletRequest;