繁体   English   中英

在yii2-oauth2-server中需要client_id和client_secret的资源所有者授权类型

[英]Resource Owner grant type requiring client_id and client_secret in yii2-oauth2-server

为什么密码grant_type必须提供客户端凭据(在此实现中)??? oauth2资源所有者规范只需要

{
    "grant_type" : "password",
    "username" : "some_user_name",
    "password" : "some_password"
}

此实现还要求client_idclient_secret与此请求一起发送以成功。

我只是想知道我是否遗漏了什么

请参阅http://andyfiedler.com/2014/09/how-secure-is-the-oauth2-resource-owner-password-credential-flow-for-single-page-apps

我想授予从SPA到受保护资源的访问权限。 在浏览器源代码中公开客户端凭据具有潜在的危险性。

此外, https://bshaffer.github.io/oauth2-server-php-docs/overview/grant-types/上的原始库不会强制资源所有者授予类型中的客户端凭据

更新1 13-12-2016

在原始图书馆阅读时,我发现他们有“公共客户”概念(即没有client_secret的客户端)。

使用公共客户端,我可以从请求中省略client_secret。 无论如何,我再次阅读资源所有者规范,并没有提到它。

这样,必须以这种方式执行资源所有者令牌请求(非标准)

{
    "grant_type" : "password",
    "username" : "some_user_name",
    "password" : "some_password"
    "cliend_id" : "some_client_id"
}

再见

谢谢

出于参考目的,OAuth2规范确实满足了这样的情况:即使客户端身份验证无法完成,没有机密的客户端仍然可以在请求正文中传递client_id参数。 在2.3.1节中,您有:

(...)授权服务器可以使用以下参数支持在请求体中包含客户端凭证:

CLIENT_ID
需要。 在第2.2节描述的注册过程中发给客户端的客户端标识符。

client_secret
需要。 客户的秘密。 如果客户端密钥是空字符串,则客户端可以省略该参数。

暂无
暂无

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

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