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

Spring security 설정을 구현했습니다. (작업중) #83

Merged
merged 7 commits into from
Jun 13, 2023

Conversation

yuus95
Copy link

@yuus95 yuus95 commented Apr 18, 2023

0418

  • 강의내용 설정했습니다. spring security 환경설정 구축

0419

  • 토큰 반환값 변경
  • 유저 권한 생성

Comment on lines +30 to +31
http.csrf()
.disable()
Copy link
Contributor

Choose a reason for hiding this comment

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

이번기회에 csrf란 무엇이고 왜 여기서는 disable하는지 알아보는 것도 좋겠습니다

ClaimData claimData = authenticationService.parseToken(accessToken);
Long userId = claimData.getUserId();
UserType userType = claimData.getUserType();
request.setAttribute("userId", userId);
Copy link
Contributor

Choose a reason for hiding this comment

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

이건 어떤 일을 하는건가요?

request.setAttribute("userId", userId);

// 인증
Authentication authentication = new UserAuthentication(userId,userType);
Copy link
Contributor

Choose a reason for hiding this comment

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

지금은 토큰안에 userId, userType만을 가지고 있는데, 이게 늘어날 가능성이 있어보여요. 그렇다면 여기 넘겨줘야할 값들이 많아질 것 같은데, 객체를 넘기는 것도 대안이 될 것 같습니다

Comment on lines +36 to +47
if (authorization != null) {
String accessToken = authorization.substring("Bearer ".length());
ClaimData claimData = authenticationService.parseToken(accessToken);
Long userId = claimData.getUserId();
UserType userType = claimData.getUserType();
request.setAttribute("userId", userId);

// 인증
Authentication authentication = new UserAuthentication(userId,userType);
SecurityContext context = SecurityContextHolder.getContext();
context.setAuthentication(authentication);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

여기서 하는 일이 많아 보이네요. 예를들어 만약 clameData가 값이 추가되거나 삭제될 경우 이 부분이 변경되어야겠네요.

@hannut91 hannut91 merged commit 8d91bb9 into CodeSoom:yuus95 Jun 13, 2023
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.

None yet

2 participants