Clean security code

This commit is contained in:
Dmitrii Cravcenco
2023-11-22 08:40:45 +02:00
parent 3bf3f92551
commit fddd02b9ce
4 changed files with 3 additions and 19 deletions

View File

@@ -62,7 +62,7 @@ public class JwtAuthenticationFilter extends OncePerRequestFilter {
response.setContentType("application/json");
ErrorResponse errorResponse = new ErrorResponse("Your session has expired. Refresh your token.");
ObjectMapper objectMapper = new ObjectMapper(); // You may need to import ObjectMapper
ObjectMapper objectMapper = new ObjectMapper();
response.getWriter().write(objectMapper.writeValueAsString(errorResponse));

View File

@@ -26,7 +26,6 @@ public class JwtService {
private long jwtExpiration;
@Value("${application.security.jwt.refresh-token.expiration}")
private long refreshExpiration;
// private final AuthenticationService authenticationService;
public String extractUsername(String token) {

View File

@@ -45,22 +45,9 @@ public class SecurityConfiguration {
.cors(Customizer.withDefaults())
.csrf(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(auth -> auth
// .requestMatchers("/api/v1/auth/**").permitAll()
.anyRequest().authenticated()
)
.oauth2Login(withDefaults());
// .exceptionHandling(exceptionHandling ->
// exceptionHandling
// .authenticationEntryPoint(authenticationEntryPoint())
// )
// .oauth2Login(oauth2Login ->
// oauth2Login
// .loginPage("/login")
// .clientRegistrationRepository(clientRegistrationRepository)
// .userInfoEndpoint(userInfoEndpoint ->
// userInfoEndpoint.userService(oAuth2UserService())
// )
// .successHandler(jwtAuthenticationSuccessHandler()));
return http.build();
}