【发布时间】:2020-02-06 11:59:08
【问题描述】:
我有一个授权服务器,我的客户端是一个 Angular 应用程序。我不是第三方应用程序。
我使用了这个 symfony 捆绑包https://github.com/trikoder/oauth2-bundle
我正在使用授权类型password。
{ "grant_type":"password", "client_id":"myclientid", "username":"john@doe.com", "password":"foo", "client_secret":"3d4a940.....3c1ea38b5" }
回应是:
{ "token_type": "Bearer", "expires_in": 60, "access_token": "eyJ0eXAi....nK0Ag", "refresh_token": "def50200dfce4da3....fdc689e5" }
access_token 的有效期只有 1 分钟,之后客户端需要使用刷新令牌才能与我的 api 对话:
{ "grant_type":"refresh_token", "client_id":"myclientid", "client_secret":"3d4a940.....3c1ea38b5" "refresh_token": "def50200dfce4da3....fdc689e5" }
client_id 和 client_secret 存储在一个表中。
我的问题是:
将client_id 和client_secret 存储在前角应用程序的本地存储中是否安全/推荐?因为它基本上代表了用户凭据,如果有人窃取它们,他们将可以访问 api。但是没有它们,客户端无法向 api 发送请求。
我爬网但找不到真正的答案,即使在 oauth 2 文档中也是如此
谢谢
【问题讨论】: