這是一個為 Laravel 框架設計的 Cometcast OpenAPI SDK 套件,提供 OIDC 認證功能。
透過 Composer 安裝套件:
composer require cometcast/php-sdk-laravel發布套件配置檔案到您的應用程式:
php artisan vendor:publish --provider="Cometcast\OpenApi\Laravel\PhpSdkLaravelServiceProvider" --tag="config"這會在 config/cometcast-openapi.php 建立配置檔案。
在您的 .env 檔案中設定以下 OIDC 相關環境變數:
# OIDC 客戶端 ID
COMETCAST_OPENAPI_CLIENT_ID=your_client_id
# OIDC 重導向 URI
COMETCAST_OPENAPI_REDIRECT_URI=your_redirect_uri
# OIDC 客戶端密鑰
COMETCAST_OPENAPI_CLIENT_SECRET=your_client_secret
# OIDC 認證伺服器基礎 URL
COMETCAST_OPENAPI_AUTH_BASEURL=https://your-auth-server.com
# OIDC 授權範圍
COMETCAST_OPENAPI_SCOPES=openid,profile,email
# OpenAPI 基礎 URL
COMETCAST_OPENAPI_BASE_URL=https://your-api-server.com
# SSL 驗證設定(開發環境可設為 false)
COMETCAST_OPENAPI_SSL_VERIFY=falseuse Cometcast\Openapi\OpenIdProvider;
public function index(OpenIdProvider $oidcProvider)
{
$provider->setPkceCode('pkce-code');
$url = $provider->getAuthorizationUrl('authorization_code', [
'ui_locales' => 'zh_TW' // 指定語系
]);
return redirect()->to($url);
}composer testPlease see CHANGELOG for more information what has changed recently.
Please see CONTRIBUTING for details.
If you discover any security related issues, please email slps970093@gmail.com instead of using the issue tracker.
The Apache License 2. Please see License File for more information.
This package was generated using the Laravel Package Boilerplate.