mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
oauth support skips authorization
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Filament\Resources\Oauth;
|
||||
|
||||
use App\Filament\OptionsTrait;
|
||||
use App\Filament\PageListSingle;
|
||||
use App\Filament\Resources\Oauth\ClientResource\Pages;
|
||||
use App\Filament\Resources\Oauth\ClientResource\RelationManagers;
|
||||
@@ -16,6 +17,8 @@ use Illuminate\Database\Eloquent\SoftDeletingScope;
|
||||
|
||||
class ClientResource extends Resource
|
||||
{
|
||||
use OptionsTrait;
|
||||
|
||||
protected static ?string $model = Client::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-collection';
|
||||
@@ -40,6 +43,11 @@ class ClientResource extends Resource
|
||||
->schema([
|
||||
Forms\Components\TextInput::make('name')->label(__('label.name')),
|
||||
Forms\Components\TextInput::make('redirect')->label(__('oauth.redirect')),
|
||||
Forms\Components\Radio::make('skips_authorization')
|
||||
->options(self::getYesNoOptions())
|
||||
->inline()
|
||||
->default(0)
|
||||
->label(__('oauth.skips_authorization')),
|
||||
|
||||
]);
|
||||
}
|
||||
@@ -52,6 +60,10 @@ class ClientResource extends Resource
|
||||
Tables\Columns\TextColumn::make('name')->label(__('label.name')),
|
||||
Tables\Columns\TextColumn::make('secret')->label(__('oauth.secret')),
|
||||
Tables\Columns\TextColumn::make('redirect')->label(__('oauth.redirect')),
|
||||
Tables\Columns\IconColumn::make('skips_authorization')
|
||||
->boolean()
|
||||
->label(__('oauth.skips_authorization'))
|
||||
,
|
||||
|
||||
])
|
||||
->filters([
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models;
|
||||
|
||||
use Laravel\Passport\Client;
|
||||
|
||||
class OauthClient extends Client
|
||||
{
|
||||
public function skipsAuthorization(): bool
|
||||
{
|
||||
return (bool)$this->skips_authorization;
|
||||
}
|
||||
}
|
||||
@@ -9,6 +9,7 @@ use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\View;
|
||||
use Illuminate\Support\ServiceProvider;
|
||||
use Illuminate\Http\Resources\Json\JsonResource;
|
||||
use Laravel\Passport\Passport;
|
||||
use Nexus\Nexus;
|
||||
use Filament\Facades\Filament;
|
||||
use NexusPlugin\Menu\Filament\MenuItemResource;
|
||||
@@ -22,6 +23,7 @@ class AppServiceProvider extends ServiceProvider
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
Passport::ignoreMigrations();
|
||||
do_action('nexus_register');
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Models\Category;
|
||||
use App\Models\Codec;
|
||||
use App\Models\Icon;
|
||||
use App\Models\Media;
|
||||
use App\Models\OauthClient;
|
||||
use App\Models\Plugin;
|
||||
use App\Models\Processing;
|
||||
use App\Models\SearchBox;
|
||||
@@ -21,6 +22,7 @@ use App\Policies\CodecPolicy;
|
||||
use Illuminate\Foundation\Support\Providers\AuthServiceProvider as ServiceProvider;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Laravel\Passport\Passport;
|
||||
|
||||
class AuthServiceProvider extends ServiceProvider
|
||||
{
|
||||
@@ -54,6 +56,7 @@ class AuthServiceProvider extends ServiceProvider
|
||||
public function boot()
|
||||
{
|
||||
$this->registerPolicies();
|
||||
Passport::useClientModel(OauthClient::class);
|
||||
|
||||
Auth::viaRequest('nexus-cookie', function (Request $request) {
|
||||
return $this->getUserByCookie($request->cookie());
|
||||
|
||||
Reference in New Issue
Block a user