sequelone/laravel-sso 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

sequelone/laravel-sso

最新稳定版本:v1.0.0

Composer 安装命令:

composer require sequelone/laravel-sso

包简介

README 文档

README

This library provides integration between Laravel Framework and SSO (Single Sign-On) https://en.wikipedia.org/wiki/Single_sign-on.

Get started

Instalation

Execute in shell:

composer require sequelone/laravel-sso

Publish the sso configuration file:

php artisan vendor:publish --provider="SequelONE\LaravelSso\SSOServiceProvider"

Broker Configuration

Set environment variables:

SSO_SERVER=http://server.address
SSO_BROKER_ID=BROKER ID
SSO_BROKER_SECRET=BROKER SECRET

Register middleware SequelONE\LaravelSso\Middleware\AttachBroker in routes key in Kernel.php.

Register sso in config/auth.php:

'sso' => [
    'driver' => 'sso',
    'model' => \App\User::class
]

Server Configuration

Set environment variable:

SSO_TYPE=server

Create App\Sso\Server.php:

<?php


namespace App\Sso;


use SequelONE\LaravelSso\Server as SsoServer;
use Jasny\ValidationResult;
use App\Models\User;

class Server extends SsoServer
{

    private $brokers = [
        '1' => 'secret1',
        '2' => 'secret2'
    ];


    /**
     * Authenticate using user credentials
     *
     * @param string $username
     * @param string $password
     * @return \Jasny\ValidationResult
     */
    protected function authenticate($username, $password)
    {
        if (!\Auth::guard('web')->validate(['email' => $username, 'password' => $password])) {
            return ValidationResult::error(trans('auth.failed'));
        }

        return ValidationResult::success();
    }

    /**
     * Get the secret key and other info of a broker
     *
     * @param string $brokerId
     * @return array
     */
    protected function getBrokerInfo($brokerId)
    {
        return !array_key_exists($brokerId, $this->brokers) ? null : [
            'id' => $brokerId,
            'secret' => $this->brokers[$brokerId]
        ];
    }

    /**
     * Get the information about a user
     *
     * @param string $username
     * @return array|object
     */
    protected function getUserInfo($username)
    {
        $user = User::whereEmail($username)->first();
        return !$user ? null : [
            'user' => $user,
        ];
    }
}

This file will describe how Server SSO identity and authenticate the brokers. More details see: https://github.com/jasny/sso

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2023-08-04