【译】使用JSON Web Tokens保护Node.js的RESTful Api
Last updated
Was this helpful?
Last updated
Was this helpful?
你是否曾经对认证是怎么工作的充满了好奇?所有复杂和抽象的背后究竟是什么?实际上,没有什么特殊的。是一种加密值的方法,是创建用户时用作标识用户的唯一标识。这个令牌会验证你的身份。它可以验证你是谁,并且授权你可以访问的各种资源。如果你恰好不了解这些字眼儿,请耐心些,下面我将揭秘这一切。
这是一个如何一步一步的将token集成到现有REST API中的教程。这个认证策略就是JWT(JSON Web Token)。如果这没有给你太多的信息,那很好,这正如我当初听到这个词时充满了好奇一样。
从实际角度来看,JWT究竟意味着什么?我们一起来看看官方给出的定义:
JSON Web Token (JWT) is a compact, URL-safe means of representing claims to be transferred between two parties. The claims in a JWT are encoded as a JSON object that is used as the payload of a JSON Web Signature (JWS) structure or as the plaintext of a JSON Web Encryption (JWE) structure, enabling the claims to be digitally signed or integrity protected with a Message Authentication Code (MAC) and/or encrypted. -
原文: