承接 eximius/laravel-nincomply-sso 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

eximius/laravel-nincomply-sso

最新稳定版本:v1.0.3

Composer 安装命令:

composer require eximius/laravel-nincomply-sso

包简介

Nincomply SSO package for Laravel Framework

README 文档

README

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

Nincomply SSO package for Laravel Framework

Installation

You can install the package via composer:

composer require eximius/laravel-nincomply-sso

You need to add the following parameters to your .env file and their appropriate values, you must have created an account on Nincomply and obtained the SSO credentials before you can do this.

NINCOMPLY_CLIENT_ID=
NINCOMPLY_CLIENT_SECRET=
NINCOMPLY_SSO_REDIRECT_URI=

(Optional) You may publish the config file with:

php artisan vendor:publish --tag="nincomply-sso-config"

This is the contents of the published config file:

return [
    'client_id' => env('NINCOMPLY_CLIENT_ID'),
    'client_secret' => env('NINCOMPLY_CLIENT_SECRET'),
    'redirect_uri' => env('NINCOMPLY_SSO_REDIRECT_URI'),
];

Usage

To get the redirect URL where users will get to sign in using their Nincomply account credentials.

use Eximius\Nincomply;
use Illuminate\Support\Facades\Redirect;

$nincomply = new Nincomply();
Redirect::to($nincomply->ssoUrl());

OR

You may use the Nincomply Facade

use Eximius\Nincomply\Facades\Nincomply;
use Illuminate\Support\Facades\Redirect;

Redirect::to(Nincomply::ssoUrl());

To get the access token. This is when the user gets redirected back to your website after signing in on the Nincomply SSO, there will be a code parameter in the URL, that is what you need to get the access token.

use Eximius\Nincomply\Facades\Nincomply;

$code = request()->query('code');
$accessToken = Nincomply::getAccessToken($code));

Sample response:
{
  "token_type": "Bearer",
  "expires_in": 1295999,
  "access_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiJ9.eyJhdWQiOiJkMDNiZjQwNC0yYWU4LTRmMjQtYTk3My1lZWIyZjNlNjA2NDEiLCJqdGkiOiIwYzZhMjBmNWJjMDBmYmZhMDk1OWQ0Nz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601e10020321ae9a1eca107720a7de48707da78f24ed7625dc0f211efdfe5d7dd7b1a38b45bec018181572f7249981ca635b381c97bbd9b86f478beeb30b56a413f4de5b44719e898618b83db44429a31b057d6369ca196dcab79f6201e692934b8028e9435a7e87b0bf7a8706847018367189aeb3e1a85341995f1767dd5c883dd4c7bc928627b39f13e35fcf699f3da97946cb3cb099c6ff3f7a794ab057f42382ab45e625f649de1844aa29cf693b6094b29c67e964087b847e7582557bf8d6b3a2b80fbf3b5a47684f37cb34e53d36a71e5b67de3b6dfb91c87aaf6407db9ba4430083e3c1327b0c88f5d95aa3f35578e18a7420a2a17490d1419c804371dcdcbbd6ce6608b6e279a6bbe4db0d821a3ef93cfea8a3c59091bba5a128c456d691449e67e3ac8b5ce8cf079464033611e5d9a29256c3415"
} 

To get the details of the authenticated user, you will need the access token from the request above.

use Eximius\Nincomply\Facades\Nincomply;

$user = Nincomply::getUser($accessToken));

Testing

composer test

Changelog

Please see CHANGELOG for more information on what has changed recently.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-01-04