Skip to content

Commit

Permalink
Merge branch 'develop' into deploy/cors
Browse files Browse the repository at this point in the history
  • Loading branch information
mingulmangul authored Nov 22, 2023
2 parents 046c991 + b134b8d commit 4b60f4b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.server.ResponseStatusException;

import com.efub.dhs.domain.member.dto.AuthRequestDto;
import com.efub.dhs.domain.member.dto.AuthResponseDto;
Expand Down Expand Up @@ -47,6 +48,9 @@ public AuthResponseDto logIn(@RequestBody @Valid AuthRequestDto requestDto) {
@ResponseStatus(HttpStatus.NO_CONTENT)
public void logout(HttpServletRequest request) {
String accessToken = resolveToken(request);
if (accessToken == null) {
throw new ResponseStatusException(HttpStatus.FORBIDDEN, "Empty Access Token.");
}
jwtService.removeJwtToken(accessToken);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public SecurityFilterChain securityFilterChain(HttpSecurity httpSecurity) throws
.authorizeRequests()
.antMatchers(HttpMethod.GET).permitAll()
.antMatchers(HttpMethod.OPTIONS).permitAll()
.antMatchers("/auth/logout").authenticated()
.antMatchers("/auth/**", "/oauth/**").permitAll()
.anyRequest().authenticated()
.and()
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/com/efub/dhs/global/jwt/entity/JwtToken.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

@Getter
@AllArgsConstructor
@RedisHash(value = "jwtToken", timeToLive = 60 * 60 * 24 * 2)
@RedisHash(value = "jwtToken", timeToLive = 60 * 60 * 24 * 14)
public class JwtToken {

@Id
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.efub.dhs.global.jwt.service;

import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;
import org.springframework.web.server.ResponseStatusException;

import com.efub.dhs.global.jwt.auth.JwtAuthProvider;
import com.efub.dhs.global.jwt.entity.JwtToken;
Expand Down Expand Up @@ -34,6 +36,6 @@ public JwtToken refreshToken(String accessToken) {

private JwtToken getJwtToken(String accessToken) {
return jwtRepository.findByAccessToken(accessToken)
.orElseThrow(() -> new SecurityException("JWT token is invalid."));
.orElseThrow(() -> new ResponseStatusException(HttpStatus.FORBIDDEN, "Invalid Access Token."));
}
}

0 comments on commit 4b60f4b

Please sign in to comment.