Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Adjust JWT Token expiration to 24 hours and update security chain. #66

Merged
merged 1 commit into from
Dec 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/main/java/ntou/auction/spring/security/JWTService.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public static String generateJWT(AuthRequest request) {
authentication = authenticationManager.authenticate(authentication);
UserDetails userDetails = (UserDetails) authentication.getPrincipal();
// millisecond
// 2 minute
long expireTime = 2 * 60 * 1000;
// one day
long expireTime = 1440 * 60 * 1000;
Date current = new Date();
Date expiration = new Date(current.getTime() + expireTime);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,13 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
.csrf(AbstractHttpConfigurer::disable)
.cors(AbstractHttpConfigurer::disable)
.authorizeHttpRequests(authorize -> authorize
.requestMatchers( "/api/v1/test/**").permitAll()
.requestMatchers(CorsUtils::isPreFlightRequest).permitAll()
.requestMatchers(HttpMethod.POST, "/api/v1/auth/log-in").permitAll()
.requestMatchers(HttpMethod.POST, "/api/v1/auth/sign-up").permitAll()
.requestMatchers(CorsUtils::isPreFlightRequest).permitAll()
.requestMatchers(HttpMethod.GET, "/api/v1/account/users/**").authenticated()
.requestMatchers(HttpMethod.GET, "/api/v1/account/users").authenticated()
.requestMatchers(HttpMethod.POST, "/api/v1/account/users").permitAll()
.requestMatchers(HttpMethod.DELETE, "/api/v1/account/users/**").hasRole(String.valueOf(Role.ADMIN))
.requestMatchers( HttpMethod.GET,"/api/v1/product/**").permitAll()
.requestMatchers(HttpMethod.GET, "/api/v1/product/products").permitAll()
.requestMatchers(HttpMethod.GET, "/api/v1/product/product/name").permitAll()
.requestMatchers(HttpMethod.GET, "/api/v1/product/product/classification").permitAll()
.requestMatchers(HttpMethod.GET, "/api/v1/product/{ID}").permitAll()
.anyRequest().authenticated())
.addFilterBefore(jwtRequestFilter, UsernamePasswordAuthenticationFilter.class)
.sessionManagement((session) -> session
Expand Down
Loading