简体   繁体   English

我是否应该在OAuth2中使用JWT令牌来提供安全的API

[英]Should I use the JWT token in the OAuth2 for Delivering a Secure API

I am developing the web application using ReactJS(Front-end UI) and Scala(Back-end API). 我正在使用ReactJS(前端UI)和Scala(后端API)开发Web应用程序。 I have implemented the backend services as microservices. 我已经将后端服务实现为微服务。

Here I have integrated OAuth2 authorization framework and used OAuth Access Tokens. 在这里,我已经集成了OAuth2授权框架并使用了OAuth访问令牌。 After user authentication, I am passing the OAuth access tokens in every sub sequent request headers. 经过用户身份验证后,我将在每个后续请求标头中传递OAuth访问令牌。

I did see in some website links, we should use JWT token in the OAuth2 flow instead of "OAuth access tokens" to delivering a Secure API. 我确实在某些网站链接中看到,我们应该在OAuth2流中使用JWT令牌而不是“ OAuth访问令牌”来提供安全API。

Should I integrate JWT token in the existing OAuth2? 是否应在现有OAuth2中集成JWT令牌? Please share your suggestions. 请分享您的建议。 Thanks. 谢谢。

OAuth2 ia an authorization protocol and does not dictate the format of the access_token so you could return a JWT from the authorization server containing the scope/permissions and the expiration. OAuth2是一种授权协议,并不规定access_token的格式,因此您可以从授权服务器返回JWT,其中包含范围/权限和到期时间。

Would recommend to go through this https://auth0.com/blog/ten-things-you-should-know-about-tokens-and-cookies/#token-oauth 建议您浏览以下https://auth0.com/blog/ten-things-you-should-know-about-tokens-and-cookies/#token-oauth

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM