Skip to content

Commit

Permalink
Merge pull request #39 from gooiman/feat/logout
Browse files Browse the repository at this point in the history
fix: blacklist ttl 추가
  • Loading branch information
koosco authored Sep 28, 2024
2 parents 8597db2 + 9d3bb5b commit bf58f51
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@
import dev.gooiman.server.common.dto.CommonSuccessDto;
import java.util.Optional;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

@Service
@RequiredArgsConstructor
public class BlackListService {

@Value("${spring.security.blacklist-validity-time}")
private Long expiration;

private final BlackListRepository blackListRepository;

public boolean isExists(String id) {
Expand All @@ -20,7 +24,7 @@ public boolean isExists(String id) {
}

public CommonSuccessDto saveBlackList(String token) {
BlackList entity = new BlackList(token);
BlackList entity = new BlackList(token, expiration);
blackListRepository.save(entity);
return CommonSuccessDto.fromEntity(true);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package dev.gooiman.server.auth.repository.entity;

import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.data.annotation.Id;
import org.springframework.data.redis.core.RedisHash;
import org.springframework.data.redis.core.TimeToLive;
Expand All @@ -11,13 +10,13 @@
public class BlackList {

@Id
private String token;
private final String token;

@TimeToLive
@Value("${spring.security.blacklist-validity-time}")
private Long expiration;
private final Long expiration;

public BlackList(String token) {
public BlackList(String token, Long expiration) {
this.token = token;
this.expiration = expiration;
}
}

0 comments on commit bf58f51

Please sign in to comment.