Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e14a9f5
GEMINI.md .gitignore์— ์ถ”๊ฐ€
NaEunMin Nov 16, 2025
6562068
feat : redis ์ฃผ์†Œ, ํฌํŠธ ์ถ”๊ฐ€
NaEunMin Nov 16, 2025
b355c20
feat : redis ์˜์กด์„ฑ ์ถ”๊ฐ€
NaEunMin Nov 16, 2025
4ff4d53
refactor : JWT ํ† ํฐ ์ถ”์ถœ ๋กœ์ง ๋ถ„๋ฆฌ
NaEunMin Nov 16, 2025
9c14785
feat : JWT ํ† ํฐ ์ถ”์ถœ ๋กœ์ง ๋ถ„๋ฆฌํ•˜์—ฌ ์ž‘์„ฑ
NaEunMin Nov 16, 2025
ecba5f0
feat : redis ์„ค์ • ์ฝ”๋“œ ์ž‘์„ฑ
NaEunMin Nov 16, 2025
b0b6970
feat : redis ๋ธ”๋ž™๋ฆฌ์ŠคํŠธ ๊ธฐ๋Šฅ ์ž‘์„ฑ
NaEunMin Nov 16, 2025
9ebcb39
feat : ํ† ํฐ ์œ ํšจ์‹œ๊ฐ„ ์–ป๋Š” ๋ฉ”์†Œ๋“œ ์ž‘์„ฑ
NaEunMin Nov 16, 2025
2e74390
feat : JwtAuthenticationFilter์— jwtExtractor ์ถ”๊ฐ€
NaEunMin Nov 16, 2025
37e4354
feat : ํšŒ์›ํƒˆํ‡ด ์—”๋“œํฌ์ธํŠธ ์ž‘์„ฑ
NaEunMin Nov 16, 2025
9294f4d
feat : ํšŒ์›ํƒˆํ‡ด ์ธํ„ฐํŽ˜์ด์Šค ์ •์˜ ๋ฐ ๊ตฌํ˜„
NaEunMin Nov 16, 2025
82eb38d
.gitignore ์ˆ˜์ •
NaEunMin Nov 16, 2025
2738c19
refactor : p8๊ฒฝ๋กœ๋ฅผ p8ํŒŒ์ผ ๋ฆฌ์†Œ์Šค๋กœ ๋ณ€๊ฒฝ
NaEunMin Nov 16, 2025
971e0fe
feat : redis์—์„œ ๋ธ”๋ž™๋ฆฌ์ŠคํŠธ ๊ฒ€์‚ฌํ•˜๋Š” ๋กœ์ง ์ถ”๊ฐ€
NaEunMin Nov 16, 2025
fb89fdc
feat : redisService ์ฃผ์ž…
NaEunMin Nov 16, 2025
cf41e8a
๋กœ์ปฌ์šฉ ์‹คํ–‰ ์„ค์ • ํŒŒ์ผ ์ž‘์„ฑ
NaEunMin Nov 16, 2025
39e5ea2
.gitignore ์ˆ˜์ •
NaEunMin Nov 16, 2025
ae4373e
refactor : ๋กœ๊ทธ์•„์›ƒ ์—”๋“œํฌ์ธํŠธ ๋งค๊ฐœ๋ณ€์ˆ˜ ์ถ”๊ฐ€
NaEunMin Nov 18, 2025
1920c6a
feat : AuthService์— logout ๋ฉ”์„œ๋“œ ์ถ”๊ฐ€
NaEunMin Nov 18, 2025
9ec6cd2
feat : AuthServiceImpl์—์„œ ๋กœ๊ทธ์•„์›ƒ ๋ฉ”์„œ๋“œ ๊ตฌํ˜„
NaEunMin Nov 18, 2025
709feae
feat : setter์ถ”๊ฐ€
NaEunMin Nov 18, 2025
fb89918
feat : RefreshToken ๋ฐœ๊ธ‰ ์‹œ userId ์ถ”๊ฐ€
NaEunMin Nov 18, 2025
4389f60
feat : User ์—”ํ‹ฐํ‹ฐ์— contentData ์˜์†์„ฑ ์ „์ด ์„ค์ •
NaEunMin Nov 18, 2025
b979a50
feat : ํšŒ์›ํƒˆํ‡ด ์—”๋“œํฌ์ธํŠธ ์ž‘์„ฑ
NaEunMin Nov 18, 2025
d4f027a
feat : ํšŒ์›ํƒˆํ‡ด์— log.info ์ถ”๊ฐ€
NaEunMin Nov 18, 2025
72ebb17
feat : MySQL์—์„œ Redis๋กœ ์ด์ „
NaEunMin Nov 18, 2025
e0a6409
์ˆ˜์ •
NaEunMin Nov 18, 2025
39a4749
feat : RefreshToken ๊ด€๋ฆฌ๋ฅผ ์œ„ํ•œ ๋ฉ”์„œ๋“œ ๊ตฌํ˜„
NaEunMin Nov 18, 2025
b804f2a
refactor : User์—”ํ‹ฐํ‹ฐ์—์„œ refreshTokenํ•„๋“œ ์‚ญ์ œ
NaEunMin Nov 18, 2025
8e11316
refactor : UserRepository์—์„œ findByRefreshToken ์‚ญ์ œ
NaEunMin Nov 18, 2025
ba33ef7
feat : ํšŒ์›ํƒˆํ‡ด ๋กœ์ง์—์„œ RefreshToken ์ œ๊ฑฐ ์ถ”๊ฐ€
NaEunMin Nov 20, 2025
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
HELP.md
GEMINI.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
Expand All @@ -25,6 +26,7 @@ bin/
out/
!**/src/main/**/out/
!**/src/test/**/out/
src/main/resources/keys/AuthKey.p8

### NetBeans ###
/nbproject/private/
Expand Down
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-security'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-oauth2-client'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'

implementation 'io.jsonwebtoken:jjwt-api:0.11.5'
implementation 'io.jsonwebtoken:jjwt-impl:0.11.5'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ public interface AuthService {
SignInUserRes signIn(SignInUserReq signInUserReq);
AppleLoginRes appleLogin(AppleIdReq appleIdReq);
SignInUserRes reissue(ReissueReq reissueReq);
void logout(Long userId);
void logout(Long userId, String token);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import com.api.tokbaro.global.jwt.AppleJwtVerifier;
import com.api.tokbaro.global.jwt.JwtTokenProvider;
import com.api.tokbaro.global.jwt.UserPrincipal;
import com.api.tokbaro.global.redis.RedisService;
import com.api.tokbaro.global.response.code.user.UserErrorResponseCode;
import com.nimbusds.jose.proc.BadJOSEException;
import com.nimbusds.jwt.JWTClaimsSet;
Expand All @@ -21,6 +22,7 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.time.Duration;
import java.util.Collections;
import java.util.Optional;

Expand All @@ -34,6 +36,8 @@ public class AuthServiceImpl implements AuthService {
private final UserRepository userRepository;
private final AppleJwtVerifier appleJwtVerifier;
private final UserService userService;
private final RedisService redisService;
private static final String REFRESH_TOKEN_KEY_PREFIX = "RT:";

//์ผ๋ฐ˜ ๋กœ๊ทธ์ธ
@Override
Expand All @@ -48,8 +52,8 @@ public SignInUserRes signIn(SignInUserReq signInUserReq) {
UserPrincipal userPrincipal = (UserPrincipal) authentication.getPrincipal();
User user = userRepository.findById(userPrincipal.getId())
.orElseThrow(()->new CustomException(UserErrorResponseCode.USER_NOT_FOUND_404));
user.setRefreshToken(tokens.refreshToken());
userRepository.save(user);

redisService.setValue(REFRESH_TOKEN_KEY_PREFIX + user.getId(), tokens.refreshToken(), Duration.ofMillis(jwtTokenProvider.getRefreshTokenValidity()));
return tokens;
}

Expand Down Expand Up @@ -102,8 +106,8 @@ public AppleLoginRes appleLogin(AppleIdReq appleIdReq) {

//accessToken, refreshํ† ํฐ ์ƒ์„ฑ
SignInUserRes tokens = jwtTokenProvider.createTokens(authentication);
user.setRefreshToken(tokens.refreshToken());
userRepository.save(user);
redisService.setValue(REFRESH_TOKEN_KEY_PREFIX + user.getId(), tokens.refreshToken(),
Duration.ofMillis(jwtTokenProvider.getRefreshTokenValidity()));
return AppleLoginRes.builder()
.grantType(tokens.grantType())
.accessToken(tokens.accessToken())
Expand All @@ -121,9 +125,16 @@ public SignInUserRes reissue(ReissueReq reissueReq) {
throw new CustomException(UserErrorResponseCode.INVALID_REFRESH_TOKEN_401);
}

//2. RefreshToken์œผ๋กœ ์‚ฌ์šฉ์ž ์กฐํšŒ
User user = userRepository.findByRefreshToken(reissueReq.getRefreshToken())
.orElseThrow(()->new CustomException(UserErrorResponseCode.USER_NOT_FOUND_FOR_TOKEN_404));
//2. RefreshToken์œผ๋กœ ์‚ฌ์šฉ์ž ID ์ถ”์ถœ ๋ฐ Redis์—์„œ ๊ฒ€์ฆ
Long userId = jwtTokenProvider.getUserIdFromToken(reissueReq.getRefreshToken());
String storedRefreshToken = redisService.getValue(REFRESH_TOKEN_KEY_PREFIX + userId);

if(storedRefreshToken == null || !storedRefreshToken.equals(reissueReq.getRefreshToken())){
throw new CustomException(UserErrorResponseCode.INVALID_REFRESH_TOKEN_401);
}

User user = userRepository.findById(userId)
.orElseThrow( ()-> new CustomException(UserErrorResponseCode.USER_NOT_FOUND_404));

//์ƒˆ๋กœ์šด ํ† ํฐ์„ ์œ„ํ•œ Authentication ๊ฐ์ฒด ์ƒ์„ฑ
UserPrincipal userPrincipal = new UserPrincipal(
Expand All @@ -133,27 +144,34 @@ public SignInUserRes reissue(ReissueReq reissueReq) {
Collections.singleton(new SimpleGrantedAuthority("ROLE_" + user.getRole().name()))
);

redisService.deleteValue(REFRESH_TOKEN_KEY_PREFIX + userId);

Authentication authentication = new UsernamePasswordAuthenticationToken(
userPrincipal,
null,
userPrincipal.getAuthorities());

//์ƒˆ๋กœ์šด ํ† ํฐ ์ƒ์„ฑ
SignInUserRes newTokens = jwtTokenProvider.createTokens(authentication);
user.setRefreshToken(newTokens.refreshToken());
userRepository.save(user);
redisService.setValue(REFRESH_TOKEN_KEY_PREFIX + user.getId(), newTokens.refreshToken(), Duration.ofMillis(jwtTokenProvider.getRefreshTokenValidity()));

return newTokens;
}

//๋กœ๊ทธ์•„์›ƒ
@Override
@Transactional
public void logout(Long userId) {
public void logout(Long userId, String accessToken) {
User user = userRepository.findById(userId)
.orElseThrow(()->new CustomException(UserErrorResponseCode.USER_NOT_FOUND_404));

user.setRefreshToken(null);
userRepository.save(user);
log.info("๋กœ๊ทธ์•„์›ƒ ์š”์ฒญ ์‚ฌ์šฉ์ž: {}", user.getUsername());

redisService.deleteValue(REFRESH_TOKEN_KEY_PREFIX + userId);
log.info("Redis์—์„œ ์‚ฌ์šฉ์ž {}์˜ Refresh Token์„ ์ œ๊ฑฐ ํ•˜์˜€์Šต๋‹ˆ๋‹ค.", user.getUsername());

Long expiration = jwtTokenProvider.getExpiration(accessToken);
redisService.addTokenToBlacklist(accessToken, expiration);
log.info("AccessToken์„ ๋ธ”๋ž™๋ฆฌ์ŠคํŠธ์— ์ถ”๊ฐ€ํ–ˆ์Šต๋‹ˆ๋‹ค. ๋งŒ๋ฃŒ ์‹œ๊ฐ„ : {}์ดˆ", expiration);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,15 @@
import com.api.tokbaro.domain.auth.service.AuthService;
import com.api.tokbaro.domain.auth.web.dto.*;
import com.api.tokbaro.domain.user.service.UserService;
import com.api.tokbaro.global.jwt.JwtExtractor;
import com.api.tokbaro.global.jwt.UserPrincipal;
import com.api.tokbaro.global.response.SuccessResponse;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;

@RestController
@RequiredArgsConstructor
Expand All @@ -34,8 +32,10 @@ public ResponseEntity<SuccessResponse<?>> signIn(@RequestBody SignInUserReq sign

//๋กœ๊ทธ์•„์›ƒ
@PostMapping("/logout")
public ResponseEntity<SuccessResponse<?>> logout(@AuthenticationPrincipal UserPrincipal userPrincipal) {
authService.logout(userPrincipal.getId());
public ResponseEntity<SuccessResponse<?>> logout(@AuthenticationPrincipal UserPrincipal userPrincipal,
@RequestHeader("Authorization")String authorizationHeader) {
String accessToken = authorizationHeader.substring(JwtExtractor.BEARER_PREFIX.length());
authService.logout(userPrincipal.getId(),accessToken);
return ResponseEntity
.status(HttpStatus.OK)
.body(SuccessResponse.emptyCustom("๋กœ๊ทธ์•„์›ƒ์— ์„ฑ๊ณตํ•˜์˜€์Šต๋‹ˆ๋‹ค."));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

@Entity
@Getter
@Setter
@Builder
@NoArgsConstructor
@AllArgsConstructor
Expand Down
10 changes: 8 additions & 2 deletions src/main/java/com/api/tokbaro/domain/user/entity/User.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ public class User extends BaseEntity {
@Column(name = "apple_id")
private String appleId; //์• ํ”Œ ๋กœ๊ทธ์ธ ์‚ฌ์šฉ์ž ๊ณ ์œ  ID

@Column(name = "refresh_token") //JWT ๋ฆฌํ”„๋ ˆ์‰ฌ ํ† ํฐ
private String refreshToken;

@Enumerated(EnumType.STRING) //Enum๊ฐ’์„ ๋ฌธ์ž์—ด๋กœ ์ €์žฅ
private Role role;
Expand All @@ -47,10 +45,18 @@ public class User extends BaseEntity {
@OneToMany(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
private List<Attendance> attendanceList;

@OneToOne(mappedBy = "user", cascade = CascadeType.ALL, orphanRemoval = true)
private ContentData contentData;


//์—ฐ๊ด€๊ด€๊ณ„ ํŽธ์˜ ๋ฉ”์„œ๋“œ
public void addAttendance(Attendance attendance) {
this.attendanceList.add(attendance);
attendance.setUser(this);
}

public void setContentData(ContentData contentData) {
this.contentData = contentData;
contentData.setUser(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ public interface UserRepository extends JpaRepository<User, Long> {

Optional<User> findByAppleId(String appleId);

Optional<User> findByRefreshToken(String refreshToken);

Boolean existsByEmail(String email);
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ public interface UserService {

MyInfoRes getMyInfo(Long userId);

void deleteUser(Long userId);
void deleteUser(Long userId, String accessToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import com.api.tokbaro.domain.user.repository.UserRepository;
import com.api.tokbaro.domain.user.web.dto.*;
import com.api.tokbaro.global.exception.CustomException;
import com.api.tokbaro.global.jwt.JwtTokenProvider;
import com.api.tokbaro.global.redis.RedisService;
import com.api.tokbaro.global.response.code.user.UserErrorResponseCode;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand All @@ -27,6 +29,8 @@ public class UserServiceImpl implements UserService {
private final PasswordEncoder passwordEncoder;
private final ContentDataRepository contentDataRepository;
private final ApnsService apnsService;
private final JwtTokenProvider jwtTokenProvider;
private final RedisService redisService;

@Override
@Transactional
Expand Down Expand Up @@ -78,11 +82,18 @@ public MyInfoRes getMyInfo(Long userId) {

@Override
@Transactional
public void deleteUser(Long userId) {
public void deleteUser(Long userId, String accessToken) {
User user = userRepository.findById(userId)
.orElseThrow(() -> new CustomException(UserErrorResponseCode.USER_NOT_FOUND_404));

log.info("ํšŒ์› ํƒˆํ‡ด ์š”์ฒญ ์‚ฌ์šฉ์ž : {}", user.getUsername());
Long expiration = jwtTokenProvider.getExpiration(accessToken);
redisService.addTokenToBlacklist(accessToken, expiration);
redisService.deleteValue("RT:" + user.getId());
log.info("์•ก์„ธ์Šค ํ† ํฐ์ด ๋ธ”๋ž™๋ฆฌ์ŠคํŠธ์— ์ถ”๊ฐ€ ๋˜์—ˆ์Šต๋‹ˆ๋‹ค. (๋งŒ๋ฃŒ์‹œ๊ฐ„ : {}์ดˆ)", expiration);

userRepository.delete(user);
log.info("์œ ์ € ๋ฐ์ดํ„ฐ๊ฐ€ ์„ฑ๊ณต์ ์œผ๋กœ ์‚ญ์ œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.");
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

import com.api.tokbaro.domain.user.service.UserService;
import com.api.tokbaro.domain.user.web.dto.*;
import com.api.tokbaro.global.jwt.JwtExtractor;
import com.api.tokbaro.global.jwt.JwtTokenProvider;
import com.api.tokbaro.global.jwt.UserPrincipal;
import com.api.tokbaro.global.response.SuccessResponse;
import jakarta.servlet.http.HttpServletRequest;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
Expand All @@ -23,6 +25,7 @@
public class UserController {

private final UserService userService;
private final JwtExtractor jwtExtractor;

//ํšŒ์›๊ฐ€์ž…
@PostMapping("/users")
Expand All @@ -33,11 +36,23 @@ public ResponseEntity<SuccessResponse<?>> signUp(@RequestBody SignUpUserReq sign
.body(SuccessResponse.success("ํšŒ์›๊ฐ€์ž…์— ์„ฑ๊ณตํ•˜์˜€์Šต๋‹ˆ๋‹ค."));
}

//์ •๋ณด ์กฐํšŒ
@GetMapping("/users/me")
public ResponseEntity<SuccessResponse<?>> getMyInfo(@AuthenticationPrincipal UserPrincipal userPrincipal){
MyInfoRes myInfoRes = userService.getMyInfo(userPrincipal.getId());
return ResponseEntity
.status(HttpStatus.OK)
.body(SuccessResponse.ok(myInfoRes));
}

//ํšŒ์›ํƒˆํ‡ด
@DeleteMapping("/users")
public ResponseEntity<SuccessResponse<?>> deleteUser(@AuthenticationPrincipal UserPrincipal userPrincipal,
@RequestHeader("Authorization")String authorizationHeader){
String accessToken = authorizationHeader.substring(JwtExtractor.BEARER_PREFIX.length());
userService.deleteUser(userPrincipal.getId(), accessToken);
return ResponseEntity
.status(HttpStatus.OK)
.body(SuccessResponse.okCustom(null,"ํšŒ์›ํƒˆํ‡ด์— ์„ฑ๊ณตํ•˜์˜€์Šต๋‹ˆ๋‹ค"));
}
}
5 changes: 3 additions & 2 deletions src/main/java/com/api/tokbaro/global/config/ApnsConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.Resource;

import java.io.File;
import java.io.IOException;
Expand All @@ -16,7 +17,7 @@
public class ApnsConfig {

@Value("${apns.p8-file-path}")
private String p8FilePath;
private Resource p8File;

@Value("${apns.team-id}")
private String teamId;
Expand All @@ -28,7 +29,7 @@ public class ApnsConfig {
public ApnsClient apnsClient() throws IOException, NoSuchAlgorithmException, InvalidKeyException {
final ApnsClient apnsClient = new ApnsClientBuilder()
.setApnsServer(ApnsClientBuilder.DEVELOPMENT_APNS_HOST)
.setSigningKey(ApnsSigningKey.loadFromPkcs8File(new File(p8FilePath), teamId, keyId))
.setSigningKey(ApnsSigningKey.loadFromInputStream(p8File.getInputStream(), teamId, keyId))
.build();
return apnsClient;
}
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/com/api/tokbaro/global/config/RedisConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package com.api.tokbaro.global.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

@Configuration
public class RedisConfig {

@Value("${REDIS_HOST}")
private String host;

@Value("${REDIS_PORT}")
private int port;

@Bean
public RedisConnectionFactory redisConnectionFactory() {
return new LettuceConnectionFactory(host, port);
}

@Bean
public RedisTemplate<String, Object> redisTemplate() {
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>();

// ์ผ๋ฐ˜์ ์ธ key:value์˜ ๊ฒฝ์šฐ ์‹œ๋ฆฌ์–ผ๋ผ์ด์ €
// ์ถ”๊ฐ€์ ์œผ๋กœ Hash๋ฅผ ์‚ฌ์šฉํ• ๋•Œ๋Š” ์ถ”ํ›„์— ์ถ”๊ฐ€ํ•˜๋ฉฐ ๋œ๋‹ค.
redisTemplate.setConnectionFactory(redisConnectionFactory());
redisTemplate.setKeySerializer(new StringRedisSerializer());
return redisTemplate;
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package com.api.tokbaro.global.config;

import com.api.tokbaro.global.jwt.JwtAuthenticationFilter;
import com.api.tokbaro.global.jwt.JwtExtractor;
import com.api.tokbaro.global.jwt.JwtTokenProvider;
import com.api.tokbaro.global.redis.RedisService;
import lombok.RequiredArgsConstructor;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
Expand All @@ -22,6 +24,8 @@
public class SecurityConfig {

private final JwtTokenProvider jwtTokenProvider;
private final JwtExtractor jwtExtractor;
private final RedisService redisService;

//๋น„๋ฐ€๋ฒˆํ˜ธ ์•”ํ˜ธํ™”
@Bean
Expand Down Expand Up @@ -57,7 +61,7 @@ public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
)

//JwtAuthenticationFilter๋ฅผ ํ•„ํ„ฐ์ฒด์ธ์— ์ถ”๊ฐ€
.addFilterBefore(new JwtAuthenticationFilter(jwtTokenProvider), UsernamePasswordAuthenticationFilter.class);
.addFilterBefore(new JwtAuthenticationFilter(jwtTokenProvider, jwtExtractor, redisService), UsernamePasswordAuthenticationFilter.class);
return http.build();
}
}
Loading