-
Notifications
You must be signed in to change notification settings - Fork 74
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
Conversation
- Security 를 활용할 때 유저권한을 흭득하여 조회할 수 있도록 수정
…UserAuthentication 파라미터 추가
http.csrf() | ||
.disable() |
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.
이번기회에 csrf란 무엇이고 왜 여기서는 disable하는지 알아보는 것도 좋겠습니다
ClaimData claimData = authenticationService.parseToken(accessToken); | ||
Long userId = claimData.getUserId(); | ||
UserType userType = claimData.getUserType(); | ||
request.setAttribute("userId", userId); |
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.
이건 어떤 일을 하는건가요?
request.setAttribute("userId", userId); | ||
|
||
// 인증 | ||
Authentication authentication = new UserAuthentication(userId,userType); |
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.
지금은 토큰안에 userId, userType만을 가지고 있는데, 이게 늘어날 가능성이 있어보여요. 그렇다면 여기 넘겨줘야할 값들이 많아질 것 같은데, 객체를 넘기는 것도 대안이 될 것 같습니다
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); | ||
} |
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.
여기서 하는 일이 많아 보이네요. 예를들어 만약 clameData가 값이 추가되거나 삭제될 경우 이 부분이 변경되어야겠네요.
0418
0419