Add oauth support
- Support azure, bitbucket, github, gitlab, google providers - Add authentication page to settings Co-authored-by: Suraj Kumar <srjkmr1024@gmail.com> Co-authored-by: Michael Castanieto <mcastanieto@gmail.com> Co-authored-by: Mike Kim <m.kim4247@gmail.com>
This commit is contained in:
28
database/migrations/2024_03_08_180457_nullable_password.php
Normal file
28
database/migrations/2024_03_08_180457_nullable_password.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('password')->nullable()->change();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('users', function (Blueprint $table) {
|
||||
$table->string('password')->nullable(false)->change();
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*/
|
||||
public function up(): void
|
||||
{
|
||||
Schema::create('oauth_settings', function (Blueprint $table) {
|
||||
$table->id();
|
||||
$table->string('provider')->unique();
|
||||
$table->boolean('enabled')->default(false);
|
||||
$table->string('client_id')->nullable();
|
||||
$table->text('client_secret')->nullable();
|
||||
$table->string('redirect_uri')->nullable();
|
||||
$table->string('tenant')->nullable();
|
||||
$table->timestamps();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*/
|
||||
public function down(): void
|
||||
{
|
||||
Schema::dropIfExists('oauth_settings');
|
||||
}
|
||||
};
|
||||
@@ -32,6 +32,7 @@ class DatabaseSeeder extends Seeder
|
||||
StandalonePostgresqlSeeder::class,
|
||||
ScheduledDatabaseBackupSeeder::class,
|
||||
ScheduledDatabaseBackupExecutionSeeder::class,
|
||||
OauthSettingSeeder::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
37
database/seeders/OauthSettingSeeder.php
Normal file
37
database/seeders/OauthSettingSeeder.php
Normal file
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
namespace Database\Seeders;
|
||||
|
||||
use App\Models\OauthSetting;
|
||||
use Illuminate\Database\Console\Seeds\WithoutModelEvents;
|
||||
use Illuminate\Database\Seeder;
|
||||
|
||||
class OauthSettingSeeder extends Seeder
|
||||
{
|
||||
/**
|
||||
* Run the database seeds.
|
||||
*/
|
||||
public function run(): void
|
||||
{
|
||||
OauthSetting::firstOrCreate([
|
||||
'id' => 0,
|
||||
'provider' => 'azure',
|
||||
]);
|
||||
OauthSetting::firstOrCreate([
|
||||
'id' => 1,
|
||||
'provider' => 'bitbucket',
|
||||
]);
|
||||
OauthSetting::firstOrCreate([
|
||||
'id' => 2,
|
||||
'provider' => 'github',
|
||||
]);
|
||||
OauthSetting::firstOrCreate([
|
||||
'id' => 3,
|
||||
'provider' => 'gitlab',
|
||||
]);
|
||||
OauthSetting::firstOrCreate([
|
||||
'id' => 4,
|
||||
'provider' => 'google',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -198,5 +198,8 @@ uZx9iFkCELtxrh31QJ68AAAAEXNhaWxANzZmZjY2ZDJlMmRkAQIDBA==
|
||||
} catch (\Throwable $e) {
|
||||
echo "Error: {$e->getMessage()}\n";
|
||||
}
|
||||
|
||||
$oauth_settings_seeder = new OauthSettingSeeder();
|
||||
$oauth_settings_seeder->run();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user