free2er / oauth-server-bundle
OAuth 服务器组件
1.0.0
2019-04-11 22:45 UTC
Requires
- php: ^7.1
- doctrine/doctrine-bundle: ^1.6
- doctrine/orm: ^2.5
- league/oauth2-server: ^7.3
- nesbot/carbon: ^2.16
- nyholm/psr7: ^1.1
- symfony/config: ^4.2
- symfony/console: ^4.2
- symfony/dependency-injection: ^4.2
- symfony/http-kernel: ^4.2
- symfony/psr-http-message-bridge: ^1.2
Requires (Dev)
- free2er/coding-standard: ^1.0
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-09-12 11:10:31 UTC
README
Symfony 组件,提供了 OAuth 2.0 授权服务器功能。授权服务器是通过使用 thephpleague/oauth2-server 库实现的。
安装
此组件可以通过 Composer 依赖管理器进行安装。
-
将组件作为项目依赖项安装
composer require free2er/oauth-server-bundle
-
启用组件
<?php // config/bundles.php return [ // ... Free2er\OAuth\OAuthServerBundle::class => ['all' => true], // ... ];
- 配置组件参数
# config/packages/oauth_server.yaml o_auth_server: encryption_key: '%env(resolve:APP_SECRET)%' private_key: file://%kernel.project_dir%/path/to/private.key private_key_password: ~ ttl: access_token: PT1H authorization_code: PT1H refresh_token: P1M grants: - League\OAuth2\Server\Grant\ClientCredentialsGrant - League\OAuth2\Server\Grant\PasswordGrant - League\OAuth2\Server\Grant\AuthCodeGrant - League\OAuth2\Server\Grant\RefreshTokenGrant
- 配置路由
# config/routes.yaml # ... oauth: resource: '@OAuthServerBundle/Resources/config/routes.yaml' prefix: /auth # ...
-
更新项目模式并注册客户端应用程序
bin/console doctrine:schema:update bin/console oauth:client:update my-client -g client_credentials
-
完成!