OAuth2 规范规定授权服务器在使用隐式授权时不得发出刷新 token 。在我们的用例中,我们使用 OAuth2 保护 RESTful API,并使用单页 Javascript 应用程序作为该 API 的客户端。由于访问 token 过期后很难重定向到授权服务器,因此我们正在寻找一种更好的方法来获取新的有效 token 。我可以考虑两种不同的方法,并想知道哪一种更好:
这两种方法都与 OpenID Connect 的方法非常相似。不幸的是,目前 OpenID Connect 的实现并不多。所以第一步是扩展 OAuth2 服务器,直到 OIC 更受欢迎。
那么应该首选哪种方法呢?
编辑 : token 端点需要客户端身份验证,这仅适用于服务器端应用程序等 secret 客户端。使用第二种方法,在我们的例子中,只有资源提供者才能让 RESTful API 刷新 token 并将其发送回客户端。我认为这将是一个安全风险。所以可能我们只有一种有效的方法。
最佳答案
来自 OAuth0 website :
If you need to authenticate your users without a login page (for example, when the user is already logged in via SSO scenario) or get a new access_token (thus simulate refreshing an expired token), you can use Silent Authentication.
至于Silent Authentication :
However, redirecting users away from your application is usually considered disruptive and should be avoided, from a UX perspective. Silent authentication lets you perform an authentication flow where Auth0 will only reply with redirects, and never with a login page.
这将允许您使用 SSO token 重新登录用户,而无需再次提示他输入凭据。
关于oauth-2.0 - 在 OAuth2 隐式授权中处理过期的访问 token ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24881802/