如何在 Symfony Oauth 2.0 中创建范围?
How to make scope in Symfony Oauth 2.0?
我用 http://blog.tankist.de/ 开发了 oauth 2.0 登录示例。但我无法决定范围。你能帮帮我吗?
要在您的应用程序中配置允许的范围,您必须编辑您的 app/config/config.yml 文件:
fos_oauth_server:
service:
options:
supported_scopes: scope1 scope2
The default behavior of the FOSOAuthServerBundle is to use scopes as roles. In the previous example, it would allow us to use the roles ROLE_SCOPE1, and ROLE_SCOPE2 (scopes are automatically uppercased).
你可以在你的控制器中这样检查
// symfony 2.6
$this->get('security.authorization_checker')->isGranted('ROLE_SCOPE1')
// symfony < 2.6
$this->get('security.context')->isGranted('ROLE_SCOPE1')
我用 http://blog.tankist.de/ 开发了 oauth 2.0 登录示例。但我无法决定范围。你能帮帮我吗?
要在您的应用程序中配置允许的范围,您必须编辑您的 app/config/config.yml 文件:
fos_oauth_server:
service:
options:
supported_scopes: scope1 scope2
The default behavior of the FOSOAuthServerBundle is to use scopes as roles. In the previous example, it would allow us to use the roles ROLE_SCOPE1, and ROLE_SCOPE2 (scopes are automatically uppercased).
你可以在你的控制器中这样检查
// symfony 2.6
$this->get('security.authorization_checker')->isGranted('ROLE_SCOPE1')
// symfony < 2.6
$this->get('security.context')->isGranted('ROLE_SCOPE1')