백엔드/node.js

<node.js> jsonwebtoken에서 payload?

studying develop 2020. 9. 19. 21:21
var token = jwt.sign({ sub: 'sjk5766' }, 'secret_key');

해당 모듈에서 페이로드로 사용되는 부분이 있는데, 페이로드가 정확히 무엇을 의미하는지 모르겠어서 찾아 본다. 위에서 sub에 해당하는 부분 같은데...

 

[jwt.io/introduction/]

 

Payload

The second part of the token is the payload, which contains the claims. Claims are statements about an entity (typically, the user) and additional data. There are three types of claims: registered, public, and private claims. 

 

페이로드는 클레임을 포함하는 부분이다... 클레임은 개체(주로 유저)에 대한 선언이다. 3가지 종류의 클레임이 있다. registerd, public, private.

 

  • Registered claims: These are a set of predefined claims which are not mandatory but recommended, to provide a set of useful, interoperable claims. Some of them are: iss (issuer), exp (expiration time), sub (subject), aud (audience), and others.

    Notice that the claim names are only three characters long as JWT is meant to be compact.

    registered claim은 사전에 정의된 의무는 아니지만 권장된는 클레임이다, 유용하고 상호작용 가능한 클레임들이다. iss, exp, sub, aud 같은 것들이 있다.
  • Public claims: These can be defined at will by those using JWTs. But to avoid collisions they should be defined in the IANA JSON Web Token Registry or be defined as a URI that contains a collision resistant namespace.
    이건 jwt의 의지에 따라 정의가 된다. ~~?

  • Private claims: These are the custom claims created to share information between parties that agree on using them and are neither registered or public claims

    이건 위에 두개가 아니지만, 서로 이 클레임을 공유하기로 한 파티들 간에 교환되기 위해 사용된다...

 

이렇게 봐도 잘 모르겠네, 음 페이로드가 옛날에 데이터통신, 네트워크 통신 과목에서 전송하는 데이터 내용같은 의미로 받아들였는데, 이것도 private claim을 보다 오는 느낌이 전달하고자 하는 정보를 dic 형태로 교환하는건가? 싶다.

'백엔드 > node.js' 카테고리의 다른 글

<node.js> node.js 교과서 - ch2 클래스  (0) 2020.10.01