Spring OAuth2 和 authentication/authorizatiuon 在 AngularJS 应用程序中

Spring OAuth2 and authentication/authorizatiuon in AngularJS application

我已经使用 RESTful 受 OAuth2 保护的 Web 服务实施 Spring 引导后端应用程序。

现在我正在开发我的客户端应用程序,它应该用 AngularJS.

编写

在开发后端应用程序期间,为了 authenticate/authorize 用户之前进行测试,我使用了以下命令(例如使用 curl):

curl -X POST -vu clientapp:123456 http://localhost:8080/oauth/token -H "Accept: application/json" -d "password=password1&username=username1&grant_type=password&scope=read%20write&client_secret=123456&client_id=clientapp"

现在我正在考虑从客户端(来自 AngularJS 应用程序)的用户 authentication/authorization 的方法。

我认为将 client_secretclient_id 等信息放在客户端(互联网浏览器)的某处是不安全的。我对么 ?如果是这样,您能否告诉我如何使用我的 OAuth2 和 AngularJS 对用户进行身份验证而不会违反安全性的正确方法。

OAuth 2.0 支持不同的授权类型(有时称为 "flows")。 OAuth 为您的用例提供了一个特殊的授权类型:implicit grant - 它可以在没有客户端密码的情况下工作。