定制 gcs/oidc-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

gcs/oidc-client

最新稳定版本:1.0.0

Composer 安装命令:

composer require gcs/oidc-client

包简介

README 文档

README

A Laravel package for delegating authentication to an OpenID Provider.

How to install

Begin by adding this package to your depedencies with the command:

composer require gcs/oidc-client

Then add the following line to the list of registered service providers in config/app.php:

GCS\OIDCClient\OIDCServiceProvider::class

Edit your config/auth.php file to use OpenID as the authentication method for your users:

'guards' => [
    'web' => [
        'driver' => 'oidc',
        ...
    ],
    ...
],

How to configure

Run the following command to publish the config/oidc.php configuration file:

php artisan vendor:publish --provider="GCS\OIDCClient\OIDCServiceProvider"

The settings to configure are the following

  • client_id This is the ID of your client application used by the OpenID provider. You should set this through an environment variable called OIDC_CLIENT_ID.
  • client_secret This is the secret code of your client application only known by the OpenID provider. You should set this through an environment variable called OIDC_CLIENT_SECRET.
  • provider_url This is base URL of the OpenID provider. You should set this through an environment variable called OIDC_PROVIDER_URL.
  • provider_name This is a short name for your OpenID provider, which will only appears in your OpenID routes. Do not use spaces. You should set this through an environment variable called OIDC_PROVIDER_NAME.
  • scopes This is a list of scopes your application will request from the OpenID provider. The openid scope is required. Add any additional scopes.

How to use

Once everything is set up, you can replace your login system with a call to the route route('oidc.signin'). For logouts, use the route route('oidc.signout').

You may want to overwrite the $redirectTo variable inside OIDCController in order to specify the route you want your users to be taken to upon successful authentication.

Another important method you may need to overwrite is retrieveByInfo inside OIDCUserProvider. This function takes the array of user attributes retrieved from the OpenID provider, and returns a User model for the authenticated user. This is where you may want to merge the info you receive from the provider with the info you hold about that user in your application database.

Developed by Cabinet Office Digital Development in October 2019.

统计信息

  • 总下载量: 371
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 6
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-10-14