の検索結果 :
×Laravel OAuth シングルサインオン(SSO) プラグインを使用すると、Laravel アプリケーションで OAuth シングルサインオンを有効にできます。シングルサインオンを使用すると、1 つのパスワードだけで Laravel アプリケーションとサービスにアクセスできます。このプラグインは、すべての OAuth 準拠の ID プロバイダーと互換性があります。ここでは、Laravel Passport を OAuth プロバイダーとして、Laravel と Laravel Passport 間でシングルサインオン (SSO) を設定する手順を順を追って説明します。Laravel OAuth クライアント シングルサインオン SSO プラグインで提供されるその他の機能の詳細については、こちらをクリックしてください。
composer require miniorange/oauth-laravel-free
{laravel-application-domain}/mo_oauth_admin
composer require laravel/passport
Laravel\Passport\PassportServiceProvider::class
namespace App;
use Laravel\Passport\HasApiTokens;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable
{
use HasApiTokens, Notifiable;
/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];
/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}
namespace App\Providers;
use Laravel\Passport\Passport;
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Gate;
class AuthServiceProvider extends ServiceProvider
{
/**
* The policy mappings for the application.
*
* @var array
*/
protected $policies = [
// 'App\Model' => 'App\Policies\ModelPolicy',
];
/**
* Register any authentication / authorization services.
*
* @return void
*/
public function boot()
{
$this->registerPolicies();
Passport::routes();
//
}
}
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
'hash' => false,
],
],
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\User;
use Auth;
class UserController extends Controller
{
public function get(Request $request)
{
$user_id = Auth::id();
$user = User::find($user_id);
return $user;
}
}
//For Laravel below 8 and migrated to the 8 version:
Route::middleware('auth:api')->get('/user/get', 'UserController@get');
OR
//For Laravel 8 new users:
use App\Http\Controllers\UserController;
Route::middleware('auth:api')->get('/user/get', 'App\Http\Controllers\UserController@get');
Which user ID should the client be assigned to?:
> 1
What should we name the client?
> Demo OAuth2 Client Account
Where should we redirect the request after authorization?
[http://localhost/auth/callback]
> Click Here to copy the Redirect URL.
New client created successfully.
Client ID: 1
Client secret: zMm0tQ9Cp7LbjK3QTgPy1pssoT1X0u7sg0YWUW01
| 範囲: | スコープフィールドは空のままにしておきます |
| エンドポイントを承認します: | http://your-laravel-site-url/oauth/authorize |
| アクセストークンエンドポイント: | http://your-laravel-site-url/oauth/token |
| UserInfo エンドポイントの取得: | http://your-laravel-site-url/api/user/get |
{laravel-application-domain}/ssologin.php?option=oauthredirect
このガイドでは、LaravelをOAuthクライアントとして使用し、Laravel Passportシングルサインオン(SSO)を正常に構成する方法を説明します。このソリューションにより、Laravel Passportのログイン認証情報を使用して、Laravelサイトへの安全なアクセスを数分以内に展開できるようになります。
助けが必要? 私たちはここにいます!
お問い合わせありがとうございます。
24 時間以内に当社からのご連絡がない場合は、お気軽にフォローアップ メールを送信してください。 info@xecurify.com
リクエストが失敗しました。
メールを送信してみてください info@xecurify.com
