奥地利 ID(电子 ID)OIDC 提供商,适用于 Laravel Socialite

dev-main 2023-02-08 23:47 UTC

This package is not auto-updated.

Last update: 2024-09-20 17:53:00 UTC


README

composer require hofstaetter/eid

安装与基本使用

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

config/services.php 中添加配置

'eid' => [    
  'client_id' => env('EID_CLIENT_ID'),
  'client_secret' => env('EID_CLIENT_SECRET'),
  'redirect' => env('EID_REDIRECT_URI'),
  'endpoint' => env('EID_ENDPOINT', 'eid.oesterreich.gv.at'),
],

添加提供者事件监听器

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

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

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

使用方法

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

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

在您的回调函数中

public function callback(Request $request)
{
    $user = Socialite::driver('eid')->user();
    // handle user and app auth
}

返回的用户字段

  • id
  • 姓名
  • 电子邮件