在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):zefy/laravel-sso开源软件地址(OpenSource Url):https://github.com/zefy/laravel-sso开源编程语言(OpenSource Language):PHP 100.0%开源软件介绍(OpenSource Introduction):Simple PHP SSO integration for LaravelThis package based on Simple PHP SSO skeleton package and made suitable for Laravel framework. Requirements
Words meanings
How it works?Client visits Broker and unique token is generated. When new token is generated we need to attach Client session to his session in Broker so he will be redirected to Server and back to Broker at this moment new session in Server will be created and associated with Client session in Broker's page. When Client visits other Broker same steps will be done except that when Client will be redirected to Server he already use his old session and same session id which associated with Broker#1. InstallationServerInstall this package using composer. $ composer require zefy/laravel-sso Copy config file to Laravel project $ php artisan vendor:publish --provider="Zefy\LaravelSSO\SSOServiceProvider" Create table where all brokers will be saved. $ php artisan migrate --path=vendor/zefy/laravel-sso/database/migrations Edit your 'api' => [
'bindings',
\Illuminate\Session\Middleware\StartSession::class,
], Now you should create brokers. You can create new broker using following Artisan CLI command: $ php artisan sso:broker:create {name} BrokerInstall this package using composer. $ composer require zefy/laravel-sso Copy config file to Laravel project $ php artisan vendor:publish --provider="Zefy\LaravelSSO\SSOServiceProvider" Change Set 3 new options in your SSO_SERVER_URL=
SSO_BROKER_NAME=
SSO_BROKER_SECRET=
Edit your protected $middlewareGroups = [
'web' => [
...
\Zefy\LaravelSSO\Middleware\SSOAutoLogin::class,
],
'api' => [
...
],
]; Last but not least, you need to edit protected function attemptLogin(Request $request)
{
$broker = new \Zefy\LaravelSSO\LaravelSSOBroker;
$credentials = $this->credentials($request);
return $broker->login($credentials[$this->username()], $credentials['password']);
}
public function logout(Request $request)
{
$broker = new \Zefy\LaravelSSO\LaravelSSOBroker;
$broker->logout();
$this->guard()->logout();
$request->session()->invalidate();
return redirect('/');
} That's all. For other Broker pages you should repeat everything from the beginning just changing your Broker name and secret in configuration file. Example SSO_SERVER_URL=https://server.test
SSO_BROKER_NAME=site1
SSO_BROKER_SECRET=892asjdajsdksja74jh38kljk2929023 |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论