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

[33] api 별 유저 권한체크 #40

Merged
merged 12 commits into from
Oct 18, 2024
Merged

[33] api 별 유저 권한체크 #40

merged 12 commits into from
Oct 18, 2024

Conversation

ohsuha
Copy link
Collaborator

@ohsuha ohsuha commented Oct 10, 2024

  • ROLE_PARTNER : 상품 등록, 수정, 삭제
  • ROLE_USER : 장바구니, 배송지, 주문, 결제 등록, 수정, 삭제
  • 권한이 필요 없는 API : 상품 리스트, 상품 상세 조회

@ohsuha ohsuha linked an issue Oct 10, 2024 that may be closed by this pull request
Copy link

@f-lab-kai-c f-lab-kai-c left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spring Security 기능을 이용해서 role을 구현했는데, 다른 방법은 없는지? 그 중에서 Spring security는 어떤 장단점을 가지는지 고려해보셨는지 궁금합니다.

var roles = (Map<String, Object>)resourceAccess.get("oauth2-client-app");

if (roles != null) {
log.info(roles.toString());

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

이 로그는 어디에 필요해서 남기는 건가요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

헉 불필요한 로그입니다. 테스트 하기 위해서 사용했는데 삭제하도록 하겠습니다.

@@ -50,4 +64,20 @@ public SecurityFilterChain securityFilterChain(HttpSecurity http) throws Excepti

return http.build();
}

private Collection<GrantedAuthority> extractAuthorities(Jwt jwt) {
var resourceAccess = (Map<String, Object>)jwt.getClaim("resource_access");

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

권한을 jwt에서 받아올 때, 관리 측면에서 신경써줘야 할 부분이 있을까요?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

토큰 만료 시간을 짧게 설정해서 탈취되더라도 오랫동안 사용되지 않게 합니다.
role 이 변경되었는데 기존 발급받은 토큰의 재사용을 막기 위해 api 서버에서 DB 체크를 추가로 합니다

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

db 체크를 추가로 하면, 토큰에 role을 집어넣을 필요가 없는거 아닌가요?

@f-lab-kai-c
Copy link

이 PR도 그렇고 과거 PR들에서 이전 작업 내용이 포함되어 있는 경우가 있는데, 어떻게 개선해볼 수 있을까요?

@ohsuha ohsuha changed the base branch from develop to feature/partner/36-create-partner October 11, 2024 06:29
@ohsuha
Copy link
Collaborator Author

ohsuha commented Oct 12, 2024

base 를 이전 PR 로 올린 브랜치로 변경 했습니다..!

@ohsuha ohsuha changed the base branch from feature/partner/36-create-partner to develop October 12, 2024 14:17
@ohsuha ohsuha merged commit b4919d6 into develop Oct 18, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

유저별 Role 추가 및 이에 따른 API 접근 권한 설정
2 participants