-
Notifications
You must be signed in to change notification settings - Fork 0
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
[#034] 인가 구현 #35
[#034] 인가 구현 #35
Conversation
async validate(payload: any) { | ||
return { userId: payload.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 의 user 필드에 userId를 담는다
|
||
return true; | ||
} | ||
} |
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.
Ownership 에서는 AuthGuard 를 통과한 요청들에 request.user.userId 가 담겨있다. 이 userId 와 파라미터의 Id 를 비교해 해당 리소스를 소유한 사람인지 비교한다
secretOrKey: configService.get('JWT_SECRET'), | ||
}); | ||
} | ||
|
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.
jwt 를 만드는 라이브러리랑 검증하는 라이브러리랑 달라서 그런데 혹시 postman 으로 했을때 통과됐나요? jwt token 은 @nestjs/jwt 에서 generate 되고 검증은 @nestjs/passport 를 사용해서 혹시나해서, 테스트 통과했으면 좋습니다~
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.
넵 통과 됩니다. passport 에서 jwt strategy를 사용해서 jwt 확인 가능합니다
이슈
체크리스트
고민한 내용
권한 가드 (OwnershipGuard)