p9d/oauth2-toolkit
最新稳定版本:v0.2.0
Composer 安装命令:
composer require p9d/oauth2-toolkit
包简介
README 文档
README
Tools to deal with OAuth2/OpenID protocols.
Use this package if your app needs to handle OAuth2/OIDC credentials to third party services, and you need something to manage them in a organized way.
$providers = [ 'your-provider-name-here' => new \P9D\OAuth2Toolkit\OpenIdConfigurationProvider( clientId: 'XXXXXXX', clientSecret: 'YYYYYYYY', configurationEndpoint: 'https://<url>/realms/ACME/.well-known/openid-configuration' ) /** * If service does not expose openid-configuration (or you want to override it), you can pass URLs directly: */ 'your-another-provider-name' => new \P9D\OAuth2Toolkit\OpenIdConfigurationProvider( clientId: 'XXXXXXX', clientSecret: 'YYYYYYYY', tokenEndpoint: 'https://example.com/oauth2/token', authorizationEndpoint: 'https://example.com/oauth2/autorize', jwksEndpoint: 'https://example.com/oauth2/jwks', ) ]; $factory = new \P9D\OAuth2Toolkit\OpenIdConfigurationFactory( $providers, \Symfony\Component\HttpClient\HttpClient::create() ); # Access provider config via: $provider = $factory->createForProvider('your-provider-name-here');
Provider configuration:
clientId- requiredclientSecret- requiredconfigurationEndpoint- URL to OpenID Discovery EndpointtokenEndpoint- OAuth2 Token EndpointauthorizationEndpoint- OAuth2 Authorization EndpointjwksEndpoint-jwks_uriendpoint in OpenID Discovery spec.
Note
You can use tokenEndpoint, authorizationEndpoint, jwksEndpoint either with both configuration Endpoint defined or not.
When defined, these properties will override values received from configuration.
All of these properties are optional, you can skip any of those you do not use.
Methods available in OpenIdConfigurationService
getAuthorizationUrl(): string
Returns a link user should be redirected to login.
parameters:
grantType,redirectUriclientId- optional - when not passed, value passed inclient_idfrom configuration will be used.scope- optionalstate- optional
getJwks(): array
Returns an array of JSON Web Key Set.
getAccessToken(): AccessToken
Exchanges code to access tokens.
parameters:
grantTypecode- optional when usingclient_credentials
统计信息
- 总下载量: 400
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-07-31