Download the PHP package studio-design/auth-sdk-php without Composer

On this page you can find all versions of the php package studio-design/auth-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package auth-sdk-php

studio-design/studio-auth-php

Auth Service の PHP SDK です。OpenAPI 仕様から自動生成されています。

ドキュメント

全エンドポイント・スキーマ・エラーレスポンスを網羅した API リファレンスは、社内開発者ポータル(Google IAP 保護・社内メンバー限定)で公開されています。ポータルのトップページから「Auth Service API」を開いてください。

要件

インストール

安定版

Snapshot 版(リリース前検証用)

main にマージされた未リリースの SDK 変更を staging で検証する用途で、Composer の prerelease 制約で snapshot タグを取得できます。

X.Y.Z は次回リリース予定のバージョン(直近 stable パッチ + 1)です。最新の snapshot タグは studio-auth-php の Tags を参照してください。

⚠️ snapshot 版は staging / CI 検証用です。本番デプロイには安定版(composer require studio-design/studio-auth-php または :^X.Y.Z)を使用してください。

使い方

ホスト設定(必須)

SDK にはデフォルトのホスト URL が設定されていません。利用前に必ず setHost() で接続先を指定してください。

AdminApi(BearerAuth)— 組織一覧取得

Admin 系のエンドポイントは Bearer トークン(JWT)で認証します。

AuthApi(ClientBasicAuth)— トークンイントロスペクション

OAuth 2.0 のトークンエンドポイントやイントロスペクションは HTTP Basic 認証(client_id / client_secret)でも認証できます。 内部サービスには次節の private_key_jwt を推奨します(共有 secret を配らずに済み、鍵は relying party の Cloud KMS から出ません)。

AuthApi(private_key_jwt)— Cloud KMS で署名した client assertion

token_endpoint_auth_method = private_key_jwt で登録したクライアントは、Basic 認証の代わりに RFC 7523 の client assertion を本文で送ります。SDK は assertion の組み立て・署名に使う鍵バージョンの選択・ 公開鍵(JWKS)の提供を Studio\Auth\ClientAssertion で行います。Cloud KMS を使う場合は composer require google/cloud-kms も必要です。

JWKS エンドポイント(認可サーバーに登録する jwks_uri の実体)は $inventory->jwks() を JSON で返すだけです。 署名に使う鍵バージョンは「公開対象(HSM・EC P-256・非インポート・ENABLED)のうち作成から 24 時間以上たった最新、 無ければ最も古い ENABLED」で、JWKS に載せる集合と同じ規則で選ばれます。 署名開始までの 24 時間(86400 秒)は固定で、設定や環境変数では短縮できません。stg の予行演習も実時間で行います。 ローテーション Job は新しい署名バージョンの作成から 25 時間以降に古い ENABLED を直接破棄予約します。 SDK は KMS 一覧の取得成功時に DESTROY_SCHEDULED を除外します。既定 300 秒のキャッシュ内、または KMS 障害時は最後の取得値を使います。

KmsKeyVersionInventory は取得値を TTL 無しで $cache->set() し、有効期限(既定 300 秒)は自分で判定します。 PSR-16 は TTL 省略時にストアが既定の有効期限を付けることを認めているため、そうしたストアでは最後の取得値が消え、 KMS 障害時に使い続けられません。TTL 省略時に無期限で保存するストアを渡してください (Laravel の Cache::store() は TTL 省略時に forever() で保存します)。

KMS 呼び出しの期限(KmsCallBudget)

KmsCallBudget::run() の中の KMS 関連の呼び出し(metadata server からのトークン取得・鍵バージョン一覧の各ページ・ 各公開鍵・署名)は、1 つの期限を共有します。呼び出しごとに残り時間を取り直すので、metadata と KMS をそれぞれ満額待たせません。 GAX のリトライは無効にするため、期限はリトライも含めた KMS の作業全体の上限です。値は呼び出し側が決めます(SDK に既定値はありません)。

HTTP の判定は transport の handler で行います。GAX は handler が返した応答をステータスを見ずに protobuf としてデコードするため、 上の $send のように 2xx 以外を例外にしないと、たとえば 503 や 302 の本文 {} が「正常な空の一覧」になり、 KmsKeyVersionInventory が最後に取れた鍵を空の一覧で上書きします(http_errors を有効にした Guzzle でも、 allow_redirects: false の 3xx は fulfilled のまま返ります。4xx / 5xx を GAX に変換させると応答本文が例外 message に入ります)。 KmsKeyVersionInventory がキャッシュを書くのは全ページと全公開鍵を取り終えたときだけで、途中で失敗したら値も取得時刻も 変えません(キャッシュがあれば前回の完全な一覧、無ければ例外)。

セキュリティ設定画面へのリンク

ユーザー本人がパスワードと 2 段階認証を設定する画面の URL を返します。API は呼びません。リンクとして置き、新しいタブで開いてください(パラメータ・戻り先は指定できません)。

アクセストークンの取得

Bearer 認証で使うアクセストークンは、Authorization Code + PKCE フロー(/oauth/authorize → /oauth/token)で発行されます。有効期限切れ時は refresh_token グラントで再発行します。フローの詳細は社内ポータルの API リファレンスを参照してください。client_id / client_secret は Auth Service 管理者がアプリケーションごとに発行します。

エラーハンドリング

API エラーは HTTP ステータスに応じた Studio\Auth\ApiException のサブクラスとして送出されます(同期・非同期メソッドで共通。未マップのステータスや接続エラーは基底の ApiException のまま)。非同期メソッドの場合は、返り値の promise がこれらの例外で reject されます:

HTTP ステータス 例外クラス
400 Studio\Auth\Exception\BadRequestException
401 Studio\Auth\Exception\UnauthorizedException
403 Studio\Auth\Exception\ForbiddenException
404 Studio\Auth\Exception\NotFoundException
409 Studio\Auth\Exception\ConflictException
422 Studio\Auth\Exception\UnprocessableEntityException
429 Studio\Auth\Exception\RateLimitException
5xx Studio\Auth\Exception\ServerException

ApiException::getProblem() は、Content-Type: application/problem+json のエラーボディが正しくデシリアライズできたときだけ RFC 9457 Problem Details(getType() / getTitle() / getStatus() / getDetail())を返します。ボディが空のとき、application/problem+json でないとき(OAuth の {"error": ...} 形式や userinfo の RFC 6750 エラーを含む)、またはデシリアライズに失敗したときは null を返します。エラー種別の判定には、従来どおり例外のサブクラス(NotFoundException 等)または getCode()(HTTP ステータスコード)を使ってください。

API エンドポイント一覧

Class Method HTTP request Description
APIApi checkSsoEnforcement GET /api/sso-enforcement/check SSO 強制判定エンドポイント
AdminApi createAdminPortalSession POST /admin/organizations/{organization_id}/admin-portal-sessions Admin Portal セッション生成
AdminApi createClient POST /admin/clients クライアント登録
AdminApi createOrganization POST /admin/organizations 組織登録
AdminApi createOrganizationInvitation POST /admin/organizations/{organization_id}/invitations メンバー招待
AdminApi deleteClient DELETE /admin/clients/{client_id} クライアント削除
AdminApi getClient GET /admin/clients/{client_id} クライアント詳細取得
AdminApi getOrganization GET /admin/organizations/{organization_id} 組織詳細取得
AdminApi listClients GET /admin/clients クライアント一覧取得
AdminApi listOrganizationInvitations GET /admin/organizations/{organization_id}/invitations 招待一覧取得
AdminApi listOrganizationMembers GET /admin/organizations/{organization_id}/members 組織メンバー一覧取得
AdminApi listOrganizations GET /admin/organizations 組織一覧取得
AdminApi removeOrganizationMember DELETE /admin/organizations/{organization_id}/members/{member_id} メンバー削除
AdminApi revokeOrganizationInvitation DELETE /admin/organizations/{organization_id}/invitations/{invitation_id} 招待取消
AdminApi updateClient PATCH /admin/clients/{client_id} クライアント更新
AdminApi updateOrganization PATCH /admin/organizations/{organization_id} 組織更新
AdminApi updateOrganizationMemberRole PATCH /admin/organizations/{organization_id}/members/{member_id} メンバーロール変更
AuthApi endSession GET /oauth/logout ログアウトエンドポイント
AuthApi endSessionPost POST /oauth/logout ログアウトエンドポイント (POST)
AuthApi getUserinfo GET /oauth/userinfo ユーザー情報の取得
AuthApi handleIdpCallback GET /oauth/callback IdP コールバック処理
AuthApi initiateAuthorization GET /oauth/authorize 認可フローの開始
AuthApi introspectToken POST /oauth/introspect トークンイントロスペクションエンドポイント
AuthApi issueTokens POST /oauth/token トークンエンドポイント
AuthApi postUserinfo POST /oauth/userinfo ユーザー情報の取得 (POST)
AuthApi revokeToken POST /oauth/revoke トークン無効化エンドポイント
OrganizationApi createMyAdminPortalSession POST /organizations/{organization_id}/admin-portal-sessions 自組織のAdmin Portal セッション生成(組織メンバー向け)
OrganizationApi getMemberMe GET /organizations/{organization_id}/members/me 自分自身の組織メンバー情報取得(組織メンバー向け)
OrganizationApi getMyOrganization GET /organizations/{organization_id} 自分が所属する組織情報取得(組織メンバー向け)
OrganizationApi listMembers GET /organizations/{organization_id}/members 組織メンバー一覧取得(組織メンバー向け)
OrganizationApi removeMember DELETE /organizations/{organization_id}/members/{member_id} メンバー削除(組織メンバー向け)
OrganizationApi sendInvitation POST /organizations/{organization_id}/invitations 組織Adminによるメンバー招待
OrganizationApi updateMemberRole PATCH /organizations/{organization_id}/members/{member_id} メンバーロール変更(組織メンバー向け)
OrganizationApi updateMyOrganization PATCH /organizations/{organization_id} 自分が所属する組織情報更新(組織メンバー向け)
SystemApi getHealthStatus GET /health ヘルスチェック
SystemApi getJwks GET /jwks JSON Web Key Set の取得
SystemApi getOAuthAuthorizationServerMetadata GET /.well-known/oauth-authorization-server OAuth 2.0 Authorization Server Metadata
SystemApi getOpenIDConfiguration GET /.well-known/openid-configuration OpenID Connect Discovery
SystemApi getServiceInfo GET / サービス情報

モデル一覧

認証方式

BearerAuth

ClientBasicAuth

コントリビュート

このリポジトリは OpenAPI 仕様から自動生成される読み取り専用のリリースミラーです。ファイルはリリースごとに上書きされるため、Pull Request は受け付けられません。バグ報告・機能要望は GitHub Issues へお願いします。

ライセンス

MIT License - LICENSE を参照してください。


このパッケージは Studio Auth Service の OpenAPI 仕様 から自動生成されています(SDK バージョン: 0.8.0)。


All versions of auth-sdk-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-curl Version *
ext-json Version *
ext-mbstring Version *
ext-openssl Version *
guzzlehttp/guzzle Version ^7.4.5 || ^8.0
guzzlehttp/psr7 Version ^2.0 || ^3.0
psr/clock Version ^1.0
psr/simple-cache Version ^1.0 || ^2.0 || ^3.0
studio-design/ecdsa-signature Version ^1.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package studio-design/auth-sdk-php contains the following files

Loading the files please wait ...