英文:
Can a jwt created in one language or library be decoded and verified in another?
问题
所以我有一个使用golang和jwt-go库发行jwt的API服务器,我想要运行一个使用node.js和jsonwebtoken库的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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论