Daily harvest
  • Introduction
  • First Chapter
  • vue初次尝试
  • Chrome Performance Tools
  • React
    • react摸索之context
    • ant design 自定义form双向绑定组件
  • Npm
    • 【译】如何防止权限错误
    • Npm-rebuild
  • 基础概念
    • my blind spot of console.log()
    • 从别人那儿新学到的关于 require 和 import 的隐藏知识
    • LRUCache.ts
    • foobar variables
  • Nodejs
    • 【译】使用JSON Web Tokens保护Node.js的RESTful Api
  • Tools
    • 新学到的linux命令
    • webstorm eslint8 报错
  • Python
    • Mac python 虚拟环境
  • Algorithm
    • LeetCode 第 1 题
Powered by GitBook
On this page

Was this helpful?

  1. Nodejs

【译】使用JSON Web Tokens保护Node.js的RESTful Api

Previousfoobar variablesNext新学到的linux命令

Last updated 5 years ago

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. -

原文:

Internet Engineering Task Force (IETF)
Securing Node.js RESTful APIs with JSON Web Tokens