一个在一种语言或库中创建的JWT能否在另一种语言或库中解码和验证?

huangapple go评论93阅读模式
英文:

Can a jwt created in one language or library be decoded and verified in another?

问题

所以我有一个使用golangjwt-go库发行jwt的API服务器,我想要运行一个使用node.jsjsonwebtoken库的socket.io服务器,需要对令牌进行解码和验证,所以我的问题是,我能否从一个库发行令牌,然后从另一个库对其进行解码和验证?

英文:

So I have an API server that uses golang and the jwt-go library to issue jwt and i want to have a socket.io server running using node.js and jsonwebtoken library that needs to decode and verify the token, so my question is can I issue a token from one library, decode and verify it from another?

答案1

得分: 8

TL;DR:是的。

使用JSON Web令牌的目的就是实现互操作性。RFC 7519明确定义了JWT的发行和验证方式,所有已知的实现(至少在项目网站上列出的实现)都遵循这个标准。

就个人而言,我曾经同时使用过jwt-go(Go)、jsonwebtoken(Node.JS)、php-jwt(PHP)和jose4j(Java、Scala),从未遇到过任何互操作性问题。

英文:

TL;DR: Yes.

Interoperability is kind of the point of using JSON web tokens. RFC 7519 explicitly defines (independent of implenentation language) how JWTs are to be issued and verified and all known implementations (at least those listed on the project website) follow this standard.

Personally, I've used jwt-go (Go), jsonwebtoken (Node.JS) and php-jwt (PHP) and jose4j (Java, Scala) all in conjunction and never encountered any interoperability issues.

huangapple
  • 本文由 发表于 2016年1月3日 00:35:47
  • 转载请务必保留本文链接:https://go.coder-hub.com/34568121.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定