일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
- ubuntu_rg_cpu_100%
- 안할수가없네
- 리엑트라우터 구버전 살리기
- checkupdates
- react
- kotlinc
- 모던디자인테마
- 선택했을까
- 나의야근
- 정규식
- 코틀린
- VSCode
- 편하게쓰자
- 반갑지는않아
- 무과금살아남기
- ReactRouter6 다운그레이드
- 야근은결국승리
- 날이새도록
- 리엑트
- vscode 수동업데이트
- 복붙하기좋은
- 해볼게
- ReactRouter 4
- 자바스크립트
- HTML 자바스크립트 태그제거
- ReactRouter withRouter
- 신기술은
- 공부할시간이
- 시플플은영원하구나
- ERR_CERT_AUTHORITY_INVALID
- Today
- Total
필사(筆寫)
1. Json web token preload claims. 본문
간단히 router에 붙여넣기 하면 작동하게끔 만들어봤다.
router.get('/jwt/create', function(req, res, next){
var jwt = require('jsonwebtoken');
var secret = "wesias7";
var payload = { email_address : "wesias7@gmail.com" };
jwt.sign(payload, secret, { algorithm : 'HS256' }, function(err, token){
jwt.verify(token, secret, function(err, decoded){
console.log(decoded);
res.send(decoded);
})
});
});
사용하기전에 설치해주자.
npm install jsonwebtoken --save
위와 같은 구문으로 손쉽게 구축이 가능할 것이다.
다음편에서는 passport와 연계해서 해봐야겠다.
하기 내용은 JSON WEB TOKEN 에 대한 규칙정의가 된 기술서.
URL : http://self-issued.info/docs/draft-ietf-oauth-json-web-token.html
4.1. Registered Claim Names
The following Claim Names are registered in the IANA "JSON Web Token Claims" registry established by Section 10.1. None of the claims defined below are intended to be mandatory to use or implement in all cases, but rather they provide a starting point for a set of useful, interoperable claims. Applications using JWTs should define which specific claims they use and when they are required or optional. All the names are short because a core goal of JWTs is for the representation to be compact.
4.1.1. "iss" (Issuer) Claim
The iss (issuer) claim identifies the principal that issued the JWT. The processing of this claim is generally application specific. The iss value is a case-sensitive string containing a StringOrURI value. Use of this claim is OPTIONAL.
4.1.2. "sub" (Subject) Claim
The sub (subject) claim identifies the principal that is the subject of the JWT. The claims in a JWT are normally statements about the subject. The subject value MUST either be scoped to be locally unique in the context of the issuer or be globally unique. The processing of this claim is generally application specific. The sub value is a case-sensitive string containing a StringOrURI value. Use of this claim is OPTIONAL.
4.1.3. "aud" (Audience) Claim
The aud (audience) claim identifies the recipients that the JWT is intended for. Each principal intended to process the JWT MUST identify itself with a value in the audience claim. If the principal processing the claim does not identify itself with a value in the aud claim when this claim is present, then the JWT MUST be rejected. In the general case, the aud value is an array of case-sensitive strings, each containing a StringOrURI value. In the special case when the JWT has one audience, the aud value MAY be a single case-sensitive string containing a StringOrURI value. The interpretation of audience values is generally application specific. Use of this claim is OPTIONAL.
4.1.4. "exp" (Expiration Time) Claim
The exp (expiration time) claim identifies the expiration time on or after which the JWT MUST NOT be accepted for processing. The processing of the exp claim requires that the current date/time MUST be before the expiration date/time listed in the exp claim. Implementers MAY provide for some small leeway, usually no more than a few minutes, to account for clock skew. Its value MUST be a number containing a NumericDate value. Use of this claim is OPTIONAL.
4.1.5. "nbf" (Not Before) Claim
The nbf (not before) claim identifies the time before which the JWT MUST NOT be accepted for processing. The processing of the nbf claim requires that the current date/time MUST be after or equal to the not-before date/time listed in the nbf claim. Implementers MAY provide for some small leeway, usually no more than a few minutes, to account for clock skew. Its value MUST be a number containing a NumericDate value. Use of this claim is OPTIONAL.
4.1.6. "iat" (Issued At) Claim
The iat (issued at) claim identifies the time at which the JWT was issued. This claim can be used to determine the age of the JWT. Its value MUST be a number containing a NumericDate value. Use of this claim is OPTIONAL.
4.1.7. "jti" (JWT ID) Claim
The jti (JWT ID) claim provides a unique identifier for the JWT. The identifier value MUST be assigned in a manner that ensures that there is a negligible probability that the same value will be accidentally assigned to a different data object; if the application uses multiple issuers, collisions MUST be prevented among values produced by different issuers as well. The jti claim can be used to prevent the JWT from being replayed. The jti value is a case-sensitive string. Use of this claim is OPTIONAL.