承接 p9d/oauth2-toolkit 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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:

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,
  • redirectUri
  • clientId - optional - when not passed, value passed in client_id from configuration will be used.
  • scope - optional
  • state - optional

getJwks(): array

Returns an array of JSON Web Key Set.

getAccessToken(): AccessToken

Exchanges code to access tokens.

parameters:

  • grantType
  • code - optional when using client_credentials

统计信息

  • 总下载量: 400
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-07-31