728x90
❏ JWT 토큰 인증 흐름
728x90
- once user verified the email, password thry're going to get back a token using JWT
- once they get that token they can send that along to access a protected route with passport, passport-jwt
- JWT module creates the token passport will actully validate. it also extract the users information from it
- we need to add login functionally, we need to accept a user's email
- validate that email that it exists and validate the password
- JWT.sign include user info, because when that token gets sent to the server
- we want decode it and it needs to know what user it is
- we also need to send a secretOrKey & expiration if we want it to expire in a certain amount of time(expiration: no more than a week, permanently)
- put it header as an authrization and send it to the server, the server will validate the user, it'll get ther user information and use it within our express server
- once we have successful match. it gives a token and token includes user info
- passport.Strategy, passport.ExtractJwt(extract payload which is userdata)
- fromAuthHeaderAsBearerToken: bear string before token
- once we call payload, find that user and validate it jwt-payload includes the user staff
- token 확인 후 : then we tried to access a protected route we first did it without the token. you saw it was authorized then we added correct token and now responding with the user data
반응형
'Frontend > 엘리스 SW 엔지니어 트랙' 카테고리의 다른 글
[ 엘리스 SW 엔지니어 트랙 ] 70일차 TL;DR (0) | 2022.01.29 |
---|---|
[ 엘리스 SW 엔지니어 트랙 ] 69일차 TL;DR (0) | 2022.01.28 |
[ 엘리스 SW 엔지니어 트랙 ] 67일차 TL;DR (0) | 2022.01.26 |
[ 엘리스 SW 엔지니어 트랙 ] 66일차(14주차 2차 팀 프로젝트) (0) | 2022.01.25 |
[ 엘리스 SW 엔지니어 트랙 ] 선택강의 - React에서의 타입스크립트 (6) | 2022.01.24 |
댓글