froxlorgmbh/sso
Composer 安装命令:
composer require froxlorgmbh/sso
包简介
PHP froxlor GmbH SSO Client for Laravel 10+
README 文档
README
PHP froxlor GmbH SSO API Client for Laravel 10+
Table of contents
Installation
composer require froxlorgmbh/sso
If you use Laravel 10+ you are already done, otherwise continue.
Add Service Provider to your app.php configuration file:
FroxlorGmbH\SSO\Providers\SSOServiceProvider::class,
Event Listener
- Add
SocialiteProviders\Manager\SocialiteWasCalledevent to yourlisten[]array inapp/Providers/EventServiceProvider. - Add your listeners (i.e. the ones from the providers) to the
SocialiteProviders\Manager\SocialiteWasCalled[]that you just created. - The listener that you add for this provider is
'FroxlorGmbH\\SSO\\Socialite\\SSOExtendSocialite@handle',. - Note: You do not need to add anything for the built-in socialite providers unless you override them with your own providers.
/**
* The event handler mappings for the application.
*
* @var array
*/
protected $listen = [
\SocialiteProviders\Manager\SocialiteWasCalled::class => [
// add your listeners (aka providers) here
'FroxlorGmbH\\SSO\\Socialite\\SSOExtendSocialite@handle',
],
];
Configuration
Copy configuration to config folder:
$ php artisan vendor:publish --provider="FroxlorGmbH\SSO\Providers\SSOServiceProvider"
Add environmental variables to your .env
SSO_KEY=
SSO_SECRET=
SSO_REDIRECT_URI=http://localhost
You will need to add an entry to the services configuration file so that after config files are cached for usage in production environment (Laravel command artisan config:cache) all config is still available.
Add to config/services.php:
'sso' => [ 'client_id' => env('SSO_KEY'), 'client_secret' => env('SSO_SECRET'), 'redirect' => env('SSO_REDIRECT_URI') ],
Examples
Basic
$sso = new FroxlorGmbH\SSO\SSO(); $sso->setClientId('abc123'); // Get SSH Key by User ID $result = $sso->getSshKeysByUserId(38); // Check, if the query was successfull if ( ! $result->success()) { die('Ooops: ' . $result->error()); } // Shift result to get single key data $sshKey = $result->shift(); echo $sshKey->name;
Setters
$sso = new FroxlorGmbH\SSO\SSO(); $sso->setClientId('abc123'); $sso->setClientSecret('abc456'); $sso->setToken('abcdef123456'); $sso = $sso->withClientId('abc123'); $sso = $sso->withClientSecret('abc123'); $sso = $sso->withToken('abcdef123456');
OAuth Tokens
$sso = new FroxlorGmbH\SSO\SSO(); $sso->setClientId('abc123'); $sso->setToken('abcdef123456'); $result = $sso->getAuthedUser(); $user = $userResult->shift();
$sso->setToken('uvwxyz456789'); $result = $sso->getAuthedUser();
$result = $sso->withToken('uvwxyz456789')->getAuthedUser();
Facade
use FroxlorGmbH\SSO\Facades\SSO; SSO::withClientId('abc123')->withToken('abcdef123456')->getAuthedUser();
Documentation
Oauth
public function retrievingToken(string $grantType, array $attributes)
PaymentIntents
public function getPaymentIntent(string $id) public function createPaymentIntent(array $parameters)
SshKeys
public function getSshKeysByUserId(int $id) public function createSshKey(string $publicKey, string $name = NULL) public function deleteSshKey(int $id)
Users
public function getAuthedUser() public function createUser(array $parameters)
Development
Run Tests
composer test
BASE_URL=xxxx CLIENT_ID=xxxx CLIENT_KEY=yyyy CLIENT_ACCESS_TOKEN=zzzz composer test
Generate Documentation
composer docs
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-06-15