Angular2 和 symfony3 FOSOAuthServerBundle 授权
Angular2 and symfony3 FOSOAuthServerBundle authorisation
我想将我的 angular2 前端应用程序与 symfony 后端连接起来。所以我正在使用 FOSOAuthServerBundle (https://github.com/FriendsOfSymfony/FOSOAuthServerBundle) 来授权我的前端应用程序,但我不清楚如何实现它。
我尝试了 "token" 端点方法,但我不得不从我的 angular2 应用程序发送 client_id 和 client_secret。而且我认为将 client_secret 存储在 public.
中是不好的
"Authorize" 端点不使用 client_secret,但要求登录表单,这对我的情况不利。
我尝试了自定义授权扩展,但 FOSOAuthServerBundle 还需要使用 client_secret.
验证客户端
使用 symfony 授权 angular2 的最佳实践是什么?可以在前端存储 client_secret 吗?或者我应该扩展 FOSOAuthServerBundle 并删除 client_secret 检查吗?
您 client_secret
的看法是正确的。更广泛地发布密钥不是有效的做法。
很遗憾,目前 FOSOAuthBundle 不适合您的需求。这个包只关注后端 OAuth 客户端。他们在 github 上有未决问题以添加对 public 客户端的支持:https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/issues/266
关于令牌和授权端点需要澄清的一件事 - 在访问您的资源的过程中必须混合使用令牌和授权端点。我建议您阅读整个 RFC 以了解 OAuth 的授权过程:https://www.rfc-editor.org/rfc/rfc6749
Hacky 解决方案:在 src/Entity/OAuth2/Client.php 中,您可以像这样覆盖 checkSecret 方法:
public function checkSecret($secret)
{
if (in_array("authorization_code", $this->getAllowedGrantTypes())) {
return true;
}
return parent::checkSecret($secret);
}
我想将我的 angular2 前端应用程序与 symfony 后端连接起来。所以我正在使用 FOSOAuthServerBundle (https://github.com/FriendsOfSymfony/FOSOAuthServerBundle) 来授权我的前端应用程序,但我不清楚如何实现它。
我尝试了 "token" 端点方法,但我不得不从我的 angular2 应用程序发送 client_id 和 client_secret。而且我认为将 client_secret 存储在 public.
中是不好的
"Authorize" 端点不使用 client_secret,但要求登录表单,这对我的情况不利。
我尝试了自定义授权扩展,但 FOSOAuthServerBundle 还需要使用 client_secret.
验证客户端
使用 symfony 授权 angular2 的最佳实践是什么?可以在前端存储 client_secret 吗?或者我应该扩展 FOSOAuthServerBundle 并删除 client_secret 检查吗?
您 client_secret
的看法是正确的。更广泛地发布密钥不是有效的做法。
很遗憾,目前 FOSOAuthBundle 不适合您的需求。这个包只关注后端 OAuth 客户端。他们在 github 上有未决问题以添加对 public 客户端的支持:https://github.com/FriendsOfSymfony/FOSOAuthServerBundle/issues/266
关于令牌和授权端点需要澄清的一件事 - 在访问您的资源的过程中必须混合使用令牌和授权端点。我建议您阅读整个 RFC 以了解 OAuth 的授权过程:https://www.rfc-editor.org/rfc/rfc6749
Hacky 解决方案:在 src/Entity/OAuth2/Client.php 中,您可以像这样覆盖 checkSecret 方法:
public function checkSecret($secret)
{
if (in_array("authorization_code", $this->getAllowedGrantTypes())) {
return true;
}
return parent::checkSecret($secret);
}