我可以在没有“允许”屏幕的情况下使用access_token重定向吗?

时间:2012-12-06 17:14:49

标签: authentication oauth oauth-2.0

我的API应该支持“官方”应用以及第三方应用。对于官方应用程序,我不希望用户明确授予访问权限(登录后)。

我是对的,我可以跳过“允许”屏幕,只要我将redirect_uri限制为http://official.service.tdl之类的内容?或者这是否具有我没想到的安全含义?

2 个答案:

答案 0 :(得分:0)

由于重定向URI来自客户端浏览器,因此您无法保证有人不会设置其浏览器来更改URI,使其看起来像是来自您的官方URI。那么问题就变成了,如果第三方应用程序绕过显式访问,你会遇到什么样的安全问题。

答案 1 :(得分:0)

对于官方应用,假设它们是机密客户端,您可以使用client credentials grant。这听起来像官方应用程序,您的API将具有预先建立的关系,您的组织也控制访问服务器。在client credentials grant中,客户端可以直接与访问服务器通信,并获取与您的API一起使用的令牌。

如果您想在重定向uri来自公司时绕过用户授权,那么您应该查看Authorization Code Redirection URI Manipulation,特别是

In order to prevent such an attack, the authorization server MUST
ensure that the redirection URI used to obtain the authorization code
is identical to the redirection URI provided when exchanging the
authorization code for an access token.  The authorization server
MUST require public clients and SHOULD require confidential clients
to register their redirection URIs.  If a redirection URI is provided
in the request, the authorization server MUST validate it against the
registered value.

您需要确保没有任何与重定向URI匹配的开放重定向。

或者您可以让用户授权访问一次并使用刷新令牌,这样他们就不需要重新授权访问。