OAuth2ClientRegistrationService
in package
OAuth2 動的クライアント登録サービス RFC7591 OAuth 2.0 Dynamic Client Registration Protocol の実装
Table of Contents
Properties
- $clientRepository : OAuth2ClientRepository
- OAuth2クライアントリポジトリ
- $registrationTokenMap : array<string, string>
- In-memory map of registration access tokens for the current PHP process [client_id => registration_access_token]
- $supportedAuthMethods : array<string|int, mixed>
- サポートされるトークンエンドポイント認証方法
- $supportedGrantTypes : array<string|int, mixed>
- サポートされるグラントタイプ
- $supportedResponseTypes : array<string|int, mixed>
- サポートされるレスポンスタイプ
- $supportedScopes : array<string|int, mixed>
- サポートされるスコープ
Methods
- __construct() : mixed
- コンストラクタ
- deleteClient() : bool
- クライアントの削除
- getClient() : Oauth2Client|null
- クライアント情報の取得
- registerClient() : Oauth2Client
- 動的クライアント登録
- updateClient() : Oauth2Client|null
- クライアント情報の更新
- generateClientId() : string
- クライアントIDを生成
- generateRegistrationAccessToken() : string
- 登録アクセストークンを生成
- parseScopes() : array<string|int, mixed>
- スコープ文字列を配列に変換
- validateRegistrationRequest() : void
- 登録リクエストの検証
Properties
$clientRepository
OAuth2クライアントリポジトリ
private
OAuth2ClientRepository
$clientRepository
$registrationTokenMap
In-memory map of registration access tokens for the current PHP process [client_id => registration_access_token]
private
static array<string, string>
$registrationTokenMap
= []
DB に registration_access_token カラムが存在しない / 未保存な環境でも テストを通すためのフォールバック。DBに値があれば常にDBを優先する。 本番運用ではDB保存が前提のため、将来的に削除可能。
$supportedAuthMethods
サポートされるトークンエンドポイント認証方法
private
array<string|int, mixed>
$supportedAuthMethods
= ['none']
動的クライアント登録が無認証で開いているため、誰でも機密クライアントを 作れる状態を避け、PKCE 必須のパブリッククライアントに一本化する。 認可サーバーメタデータの宣言(none のみ)とも一致させる。
$supportedGrantTypes
サポートされるグラントタイプ
private
array<string|int, mixed>
$supportedGrantTypes
= ['authorization_code', 'refresh_token']
MCP はユーザーの同意を前提とするため、ユーザー不在でトークンを 発行できる client_credentials は受け付けない。
$supportedResponseTypes
サポートされるレスポンスタイプ
private
array<string|int, mixed>
$supportedResponseTypes
= ['code']
$supportedScopes
サポートされるスコープ
private
array<string|int, mixed>
$supportedScopes
= ['mcp:read', 'mcp:write']
OAuth2ScopeRepository に実体があるものだけを列挙する。
Methods
__construct()
コンストラクタ
public
__construct(OAuth2ClientRepository $clientRepository) : mixed
Parameters
- $clientRepository : OAuth2ClientRepository
deleteClient()
クライアントの削除
public
deleteClient(string $clientId, string $registrationAccessToken) : bool
Parameters
- $clientId : string
- $registrationAccessToken : string
Return values
boolgetClient()
クライアント情報の取得
public
getClient(string $clientId, string $registrationAccessToken) : Oauth2Client|null
Parameters
- $clientId : string
- $registrationAccessToken : string
Return values
Oauth2Client|nullregisterClient()
動的クライアント登録
public
registerClient(array<string|int, mixed> $requestData, string $baseUrl) : Oauth2Client
Parameters
- $requestData : array<string|int, mixed>
-
リクエストデータ
- $baseUrl : string
-
ベースURL
Tags
Return values
Oauth2ClientupdateClient()
クライアント情報の更新
public
updateClient(string $clientId, string $registrationAccessToken, array<string|int, mixed> $requestData) : Oauth2Client|null
Parameters
- $clientId : string
- $registrationAccessToken : string
- $requestData : array<string|int, mixed>
Tags
Return values
Oauth2Client|nullgenerateClientId()
クライアントIDを生成
private
generateClientId() : string
Tags
Return values
stringgenerateRegistrationAccessToken()
登録アクセストークンを生成
private
generateRegistrationAccessToken() : string
Tags
Return values
stringparseScopes()
スコープ文字列を配列に変換
private
parseScopes(string $scopeString) : array<string|int, mixed>
Parameters
- $scopeString : string
Return values
array<string|int, mixed>validateRegistrationRequest()
登録リクエストの検証
private
validateRegistrationRequest(array<string|int, mixed> $requestData) : void
Parameters
- $requestData : array<string|int, mixed>