chornthorn/wso2-is

WSO2 Identity Server OAuth2 Provider for Laravel Socialite

v1.0.7 2023-09-01 08:11 UTC

This package is auto-updated.

Last update: 2024-09-30 02:05:25 UTC


README

Latest Version on Packagist GitHub issues-closed Total Downloads

composer require chornthorn/wso2-is

安装与基本使用

请参阅基本安装指南,然后按照以下特定提供者说明操作。

config/services.php 中添加配置

'wso2is' => [
  'client_id' => env('WSO2IS_CLIENT_ID'),
  'client_secret' => env('WSO2IS_CLIENT_SECRET'),
  'redirect' => env('WSO2IS_REDIRECT_URI'),
  'base_url' => env('WSO2IS_BASE_URL'),
],

.env 中添加配置

登录您的 WSO2 Identity Server 并创建一个新的 OAuth2 应用程序。然后,将以下配置添加到您的 .env 文件中。

WSO2IS_CLIENT_ID=your-client-id
WSO2IS_CLIENT_SECRET=your-client-secret
WSO2IS_REDIRECT_URI=https://your-callback-url
WSO2IS_BASE_URL=https://your-identity-server.com/oauth2

添加提供者事件监听器

配置包的监听器以监听 SocialiteWasCalled 事件。

将事件添加到 app/Providers/EventServiceProvider 中的 listen[] 数组中。有关详细说明,请参阅基本安装指南

protected $listen = [
    \SocialiteProviders\Manager\SocialiteWasCalled::class => [
        // ... other providers
         \SocialiteProviders\WSO2IS\Wso2IsExtendSocialite::class . '@handle',
    ],
];

用法

现在您应该能够像通常使用 Socialite 一样使用此提供者(假设您已安装了 facade)

return Socialite::driver('wso2is')->redirect();

返回的用户字段

  • id
  • 昵称
  • 姓名
  • 邮箱