-
Notifications
You must be signed in to change notification settings - Fork 5
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
Feat: blackList구현 #103
Merged
jjh4450
merged 32 commits into
kakao-tech-campus-2nd-step3:weekly/10
from
youcastle03:weekly/10
Nov 11, 2024
Merged
Feat: blackList구현 #103
Changes from 28 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
ee67cb7
Merge pull request #69 from kakao-tech-campus-2nd-step3/weekly/9
nimunsang d7e1408
feat:sameSite:None
youcastle03 5a98cc6
fix: 리프레시토큰 쿠키 만료싲간 재설정
youcastle03 abdf3eb
fix:ExceptionHandler Return raw type
youcastle03 16b5f7d
fix:wishListNotFoundException httpStatus type
youcastle03 2e304f3
feat: redis config
youcastle03 2a0d0de
feat: redis config
youcastle03 ff5e368
fix:오타 수정
youcastle03 662ecdc
Merge pull request #97 from kakao-tech-campus-2nd-step3/weekly/10
nimunsang 50c38c8
feat:BlackListRepository
youcastle03 c8b0a0f
feat:TokenService
youcastle03 f9dc815
feat:로그아웃시 블랙리스트 등록
youcastle03 ee0507e
refactor: cookie 반환 취소
youcastle03 2a02980
feat: blackList
youcastle03 06cedc0
feat:sameSite:None
youcastle03 6af155f
fix: 리프레시토큰 쿠키 만료싲간 재설정
youcastle03 0e3eba3
fix:ExceptionHandler Return raw type
youcastle03 362c3b6
fix:wishListNotFoundException httpStatus type
youcastle03 5d28de9
feat: redis config
youcastle03 7590486
feat: redis config
youcastle03 4e8205e
fix:오타 수정
youcastle03 a217d0c
feat:BlackListRepository
youcastle03 bd74d07
feat:TokenService
youcastle03 5b7670c
feat:로그아웃시 블랙리스트 등록
youcastle03 ac02e1a
refactor: cookie 반환 취소
youcastle03 1f526f6
feat: blackList
youcastle03 ead10d9
chore: 빈칸 수정
youcastle03 ce7b582
충돌 해결
youcastle03 7823f9f
fix: test용 url수정
youcastle03 c89b328
fix: url수정
youcastle03 b340dd2
feat:testyml에 redis정보 수정
youcastle03 d4717e2
fix:test yml수정
youcastle03 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
package jeje.work.aeatbe.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.RedisStandaloneConfiguration; | ||
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.data.redis.repository.configuration.EnableRedisRepositories; | ||
import org.springframework.data.redis.serializer.StringRedisSerializer; | ||
|
||
@Configuration | ||
@EnableRedisRepositories | ||
public class RedisConfig { | ||
|
||
@Value("${spring.data.redis.host}") | ||
private String host; | ||
|
||
@Value("${spring.data.redis.port}") | ||
private int port; | ||
|
||
@Value("${spring.data.redis.password}") | ||
private String password; | ||
|
||
@Value("${spring.data.redis.username}") | ||
private String username; | ||
|
||
@Bean | ||
public RedisConnectionFactory redisConnectionFactory() { | ||
RedisStandaloneConfiguration config = new RedisStandaloneConfiguration(host, port); | ||
config.setUsername(username); | ||
config.setPassword(password); | ||
return new LettuceConnectionFactory(config); | ||
|
||
} | ||
|
||
|
||
@Bean | ||
public RedisTemplate<String, Object> redisTemplate() { | ||
RedisTemplate<String, Object> redisTemplate = new RedisTemplate<>(); | ||
redisTemplate.setConnectionFactory(redisConnectionFactory()); | ||
|
||
redisTemplate.setKeySerializer(new StringRedisSerializer()); | ||
redisTemplate.setValueSerializer(new StringRedisSerializer()); | ||
|
||
redisTemplate.setHashKeySerializer(new StringRedisSerializer()); | ||
redisTemplate.setHashValueSerializer(new StringRedisSerializer()); | ||
|
||
redisTemplate.setDefaultSerializer(new StringRedisSerializer()); | ||
|
||
return redisTemplate; | ||
} | ||
|
||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package jeje.work.aeatbe.entity; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import org.springframework.data.annotation.Id; | ||
import org.springframework.data.redis.core.RedisHash; | ||
|
||
@Getter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@RedisHash(value = "blackList" , timeToLive = 3600) | ||
public class BlackList { | ||
|
||
@Id | ||
private String token; | ||
|
||
private String userId; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
src/main/java/jeje/work/aeatbe/repository/BlackListRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
package jeje.work.aeatbe.repository; | ||
|
||
import java.util.Optional; | ||
import jeje.work.aeatbe.entity.BlackList; | ||
import org.springframework.data.repository.CrudRepository; | ||
|
||
public interface BlackListRepository extends CrudRepository<BlackList, String> { | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package jeje.work.aeatbe.service; | ||
|
||
import java.util.Optional; | ||
import jeje.work.aeatbe.entity.BlackList; | ||
import jeje.work.aeatbe.repository.BlackListRepository; | ||
import lombok.RequiredArgsConstructor; | ||
import org.springframework.data.redis.core.RedisTemplate; | ||
import org.springframework.stereotype.Service; | ||
|
||
@Service | ||
@RequiredArgsConstructor | ||
public class TokenService { | ||
|
||
private final BlackListRepository blackListRepository; | ||
private final RedisTemplate<String, Object> redisTemplate; | ||
|
||
/** | ||
* 로그아웃된 엑세스 토큰을 블랙 리스트에 등록 | ||
* @param accessToken | ||
* @param userId | ||
*/ | ||
public void addBlackList (String accessToken, String userId){ | ||
accessToken = removePrefix(accessToken); | ||
BlackList blackList = new BlackList(accessToken, userId); | ||
blackListRepository.save(blackList); | ||
} | ||
|
||
/** | ||
* 토큰의 Bearer prefix 제거 | ||
* @param token | ||
* @return prefix없는 순수 토큰 | ||
*/ | ||
public String removePrefix(String token){ | ||
if(token.startsWith("Bearer ")){ | ||
return token.substring(7); | ||
} | ||
return token; | ||
} | ||
|
||
/** | ||
* 블랙시스트에 있는지 확인 | ||
* @param accessToken | ||
* @return 유무 | ||
*/ | ||
public boolean isInBlackList(String accessToken){ | ||
Optional<BlackList> blackList = blackListRepository.findById(accessToken); | ||
|
||
return !blackList.isEmpty(); | ||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,21 +36,30 @@ spring: | |
file: ./docker/compose.yml | ||
skip: | ||
in-tests: false | ||
|
||
|
||
data: | ||
redis: | ||
host: ${REDIS_HOST} | ||
port: ${REDIS_PORT} | ||
url: ${REDIS_URL} | ||
password: ${REDIS_PASSWORD} | ||
username: ${REDIS_ID} | ||
|
||
|
||
kakao: | ||
client_id: ${KAKAO_CLIENT_ID} | ||
redirect_url: https://${FRONTEND_DOMAIN}/login/redirect | ||
# redirect_url: https://${FRONTEND_DOMAIN}/login/redirect | ||
redirect_url: http://localhost:8080/api/users/callback | ||
auth_url: https://kauth.kakao.com/oauth/authorize | ||
logout_url: https://kauth.kakao.com/oauth/logout | ||
logout_redirect_url: https://${FRONTEND_DOMAIN}/logout/redirect | ||
# logout_redirect_url: https://${FRONTEND_DOMAIN}/logout/redirect | ||
logout_redirect_url: http://localhost:8080/api/users/logoutWithKakao/callback | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 엔드포인트 완전히 바뀐건가요? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 아 테스트 한다고 바꿔놨다가 안바꿨네요 수정하겠습니다. |
||
|
||
haccp: | ||
service_key : ${SERVICE_KEY} | ||
base_url : https://apis.data.go.kr/B553748/CertImgListServiceV3 | ||
|
||
default: | ||
image: https://www.notion.so/image/https%3A%2F%2Fprod-files-secure.s3.us-west-2.amazonaws.com%2Fbafebf27-4e21-4ed6-99e1-983eb90ad9c0%2F75c38d1f-215b-4536-a401-18cf179bf119%2Fimage.png?table=block&id=137a63f1-9420-8046-9cb6-d218151fd876&cache=v2 | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.jeje.work로 수정 부탁 드립니다.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
쿠키 사용 안할 것 같습니다