mirror of
https://github.com/Kovah/LinkAce.git
synced 2025-01-17 13:18:21 +01:00
This commit is contained in:
parent
72a210d2be
commit
b9c78b5ad7
@ -2,6 +2,7 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Actions\Settings\SetDefaultSettingsForUser;
|
||||
use App\Models\User;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Laravel\Socialite\Facades\Socialite;
|
||||
@ -12,9 +13,7 @@ class SocialiteController extends Controller
|
||||
{
|
||||
$this->authorizeOauthRequest($provider);
|
||||
|
||||
return Socialite::driver($provider)->redirect()->setTargetUrl(
|
||||
route('auth.oauth.callback', ['provider' => $provider])
|
||||
);
|
||||
return Socialite::driver($provider)->redirect();
|
||||
}
|
||||
|
||||
public function callback(string $provider)
|
||||
@ -28,6 +27,7 @@ class SocialiteController extends Controller
|
||||
if (User::where('email', $authUser->getEmail())->exists()) {
|
||||
$user = User::where('email', $authUser->getEmail())->first();
|
||||
$user->update([
|
||||
'name' => $authUser->getNickname(),
|
||||
'oauth_id' => $authUser->id,
|
||||
'oauth_provider' => $provider,
|
||||
'oauth_token' => $authUser->token ?? null,
|
||||
@ -49,6 +49,10 @@ class SocialiteController extends Controller
|
||||
'oauth_token_secret' => $authUser->tokenSecret ?? null,
|
||||
'oauth_refresh_token' => $authUser->refreshToken ?? null,
|
||||
]);
|
||||
|
||||
if ($user->wasRecentlyCreated) {
|
||||
(new SetDefaultSettingsForUser($user))->up();
|
||||
}
|
||||
}
|
||||
|
||||
Auth::login($user);
|
||||
|
@ -12,6 +12,6 @@ class VerifyCsrfToken extends Middleware
|
||||
* @var array
|
||||
*/
|
||||
protected $except = [
|
||||
//
|
||||
'auth/oauth/oidc/callback'
|
||||
];
|
||||
}
|
||||
|
@ -28,8 +28,9 @@ class EventServiceProvider extends ServiceProvider
|
||||
\SocialiteProviders\Cognito\CognitoExtendSocialite::class . '@handle',
|
||||
\SocialiteProviders\FusionAuth\FusionAuthExtendSocialite::class . '@handle',
|
||||
\SocialiteProviders\Keycloak\KeycloakExtendSocialite::class . '@handle',
|
||||
\SocialiteProviders\OIDC\OIDCExtendSocialite::class.'@handle',
|
||||
\SocialiteProviders\Okta\OktaExtendSocialite::class . '@handle',
|
||||
//\SocialiteProviders\Zitadel\ZitadelExtendSocialite::class . '@handle',
|
||||
//\SocialiteProviders\Zitadel\ZitadelExtendSocialite::class . '@handle', // @TODO enabling this leads to SocialiteProviders\Zitadel\ZitadelExtendSocialite does not exist exception
|
||||
],
|
||||
];
|
||||
|
||||
|
@ -40,7 +40,8 @@
|
||||
"spatie/laravel-permission": "^6.3.0",
|
||||
"spatie/laravel-settings": "^3.2.3",
|
||||
"symfony/http-client": "^6.0",
|
||||
"symfony/mailgun-mailer": "^6.0"
|
||||
"symfony/mailgun-mailer": "^6.0",
|
||||
"kovah/laravel-socialite-oidc": "dev-main"
|
||||
},
|
||||
"require-dev": {
|
||||
"barryvdh/laravel-debugbar": "^3.2",
|
||||
@ -58,6 +59,10 @@
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/Kovah/netscape-bookmark-parser"
|
||||
},
|
||||
{
|
||||
"type": "git",
|
||||
"url": "https://github.com/Kovah/laravel-socialite-oidc"
|
||||
}
|
||||
],
|
||||
"autoload": {
|
||||
|
60
composer.lock
generated
60
composer.lock
generated
@ -4,7 +4,7 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "b6189b53cf142ded12f56ea8042bb896",
|
||||
"content-hash": "641cd472a27cd7ab4a6138d87bc1ae45",
|
||||
"packages": [
|
||||
{
|
||||
"name": "aws/aws-crt-php",
|
||||
@ -1926,6 +1926,63 @@
|
||||
],
|
||||
"time": "2023-03-01T21:17:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "kovah/laravel-socialite-oidc",
|
||||
"version": "dev-main",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/Kovah/laravel-socialite-oidc",
|
||||
"reference": "5bb9f107ec742505d15f09fafd519b4ce2512bc6"
|
||||
},
|
||||
"require": {
|
||||
"ext-json": "*",
|
||||
"illuminate/http": "^9.0 | ^10.0 | ^11.0",
|
||||
"illuminate/support": "^9.0 | ^10.0 | ^11.0",
|
||||
"php": "^8.1",
|
||||
"socialiteproviders/manager": "^4.0"
|
||||
},
|
||||
"conflict": {
|
||||
"jp-gauthier/socialiteproviders-oidc": "*"
|
||||
},
|
||||
"default-branch": true,
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"SocialiteProviders\\OIDC\\": "src"
|
||||
}
|
||||
},
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "JPG Dev",
|
||||
"homepage": "https://jpgdev.com"
|
||||
},
|
||||
{
|
||||
"name": "Kevin Woblick",
|
||||
"email": "mail@kovah.de",
|
||||
"homepage": "https://kovah.de",
|
||||
"role": "Developer"
|
||||
}
|
||||
],
|
||||
"description": "OpenID Connect OAuth2 Provider for Laravel Socialite",
|
||||
"homepage": "https://github.com/kovah/laravel-socialite-oidc",
|
||||
"keywords": [
|
||||
"laravel",
|
||||
"oauth",
|
||||
"oidc",
|
||||
"provider",
|
||||
"socialite"
|
||||
],
|
||||
"funding": [
|
||||
{
|
||||
"type": "github",
|
||||
"url": "https://github.com/sponsors/kovah"
|
||||
}
|
||||
],
|
||||
"time": "2024-09-17T22:50:54+00:00"
|
||||
},
|
||||
{
|
||||
"name": "laracasts/flash",
|
||||
"version": "3.2.3",
|
||||
@ -13346,6 +13403,7 @@
|
||||
"minimum-stability": "dev",
|
||||
"stability-flags": {
|
||||
"shaarli/netscape-bookmark-parser": 20,
|
||||
"kovah/laravel-socialite-oidc": 20,
|
||||
"roave/security-advisories": 20
|
||||
},
|
||||
"prefer-stable": true,
|
||||
|
@ -37,6 +37,7 @@ return [
|
||||
'github',
|
||||
'gitlab',
|
||||
'keycloak',
|
||||
'oidc',
|
||||
'okta',
|
||||
'zitadel',
|
||||
],
|
||||
|
@ -68,7 +68,6 @@ return [
|
||||
'logout_uri' => env('OAUTH_COGNITO_SIGN_OUT_URL'),
|
||||
],
|
||||
|
||||
|
||||
'fusionauth' => [
|
||||
'enabled' => env('OAUTH_FUSIONAUTH_ENABLED', false),
|
||||
'base_url' => env('OAUTH_FUSIONAUTH_BASE_URL'),
|
||||
@ -107,6 +106,15 @@ return [
|
||||
'redirect' => '/auth/oauth/keycloak/callback',
|
||||
],
|
||||
|
||||
'oidc' => [
|
||||
'enabled' => env('OAUTH_OIDC_ENABLED', false),
|
||||
'base_url' => env('OAUTH_OIDC_BASE_URL'),
|
||||
'client_id' => env('OAUTH_OIDC_CLIENT_ID'),
|
||||
'client_secret' => env('OAUTH_OIDC_CLIENT_SECRET'),
|
||||
'scopes' => env('OAUTH_OIDC_SCOPES'),
|
||||
'redirect' => '/auth/oauth/oidc/callback',
|
||||
],
|
||||
|
||||
'okta' => [
|
||||
'enabled' => env('OAUTH_OKTA_ENABLED', false),
|
||||
'base_url' => env('OAUTH_OKTA_BASE_URL'),
|
||||
|
@ -11,9 +11,9 @@ return new class extends Migration {
|
||||
$table->after('remember_token', function (Blueprint $table) {
|
||||
$table->string('oauth_id')->nullable();
|
||||
$table->string('oauth_provider')->nullable();
|
||||
$table->string('oauth_token')->nullable();
|
||||
$table->string('oauth_token_secret')->nullable();
|
||||
$table->string('oauth_refresh_token')->nullable();
|
||||
$table->text('oauth_token')->nullable();
|
||||
$table->text('oauth_token_secret')->nullable();
|
||||
$table->text('oauth_refresh_token')->nullable();
|
||||
});
|
||||
|
||||
$table->string('password')->nullable()->change();
|
||||
|
@ -8,6 +8,7 @@ return [
|
||||
'password' => 'Password',
|
||||
'password_confirm' => 'Confirm the Password',
|
||||
'login' => 'Login',
|
||||
'login_with' => 'Login with',
|
||||
'logout' => 'Logout',
|
||||
'remember_me' => 'Remember me',
|
||||
'go_to_dashboard' => 'Go to the Dashboard',
|
||||
|
@ -1,6 +1,6 @@
|
||||
<div class="card {{ config('auth.oauth.regular_login_disabled') ? '' : 'mt-4' }}">
|
||||
<div class="card-body">
|
||||
<h2 class="h6">Login with</h2>
|
||||
<h2 class="h6">@lang('linkace.login_with')</h2>
|
||||
<div class="d-flex flex-wrap gap-2">
|
||||
@foreach(config('auth.oauth.providers') as $provider)
|
||||
@if(config('services.'.$provider.'.enabled') === true)
|
||||
|
1
resources/views/components/icon/brand/cognito.blade.php
Normal file
1
resources/views/components/icon/brand/cognito.blade.php
Normal file
@ -0,0 +1 @@
|
||||
<svg {{ $attributes->merge(['class' => 'icon', 'aria-label' => 'AWS Cognito']) }} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 640 512"><path d="M180.41 203.01c-.72 22.65 10.6 32.68 10.88 39.05a8.164 8.164 0 0 1-4.1 6.27l-12.8 8.96a10.66 10.66 0 0 1-5.63 1.92c-.43-.02-8.19 1.83-20.48-25.61a78.608 78.608 0 0 1-62.61 29.45c-16.28.89-60.4-9.24-58.13-56.21-1.59-38.28 34.06-62.06 70.93-60.05 7.1.02 21.6.37 46.99 6.27v-15.62c2.69-26.46-14.7-46.99-44.81-43.91-2.4.01-19.4-.5-45.84 10.11-7.36 3.38-8.3 2.82-10.75 2.82-7.41 0-4.36-21.48-2.94-24.2 5.21-6.4 35.86-18.35 65.94-18.18a76.857 76.857 0 0 1 55.69 17.28 70.285 70.285 0 0 1 17.67 52.36l-.01 69.29zM93.99 235.4c32.43-.47 46.16-19.97 49.29-30.47 2.46-10.05 2.05-16.41 2.05-27.4-9.67-2.32-23.59-4.85-39.56-4.87-15.15-1.14-42.82 5.63-41.74 32.26-1.24 16.79 11.12 31.4 29.96 30.48zm170.92 23.05c-7.86.72-11.52-4.86-12.68-10.37l-49.8-164.65c-.97-2.78-1.61-5.65-1.92-8.58a4.61 4.61 0 0 1 3.86-5.25c.24-.04-2.13 0 22.25 0 8.78-.88 11.64 6.03 12.55 10.37l35.72 140.83 33.16-140.83c.53-3.22 2.94-11.07 12.8-10.24h17.16c2.17-.18 11.11-.5 12.68 10.37l33.42 142.63L420.98 80.1c.48-2.18 2.72-11.37 12.68-10.37h19.72c.85-.13 6.15-.81 5.25 8.58-.43 1.85 3.41-10.66-52.75 169.9-1.15 5.51-4.82 11.09-12.68 10.37h-18.69c-10.94 1.15-12.51-9.66-12.68-10.75L328.67 110.7l-32.78 136.99c-.16 1.09-1.73 11.9-12.68 10.75h-18.3zm273.48 5.63c-5.88.01-33.92-.3-57.36-12.29a12.802 12.802 0 0 1-7.81-11.91v-10.75c0-8.45 6.2-6.9 8.83-5.89 10.04 4.06 16.48 7.14 28.81 9.6 36.65 7.53 52.77-2.3 56.72-4.48 13.15-7.81 14.19-25.68 5.25-34.95-10.48-8.79-15.48-9.12-53.13-21-4.64-1.29-43.7-13.61-43.79-52.36-.61-28.24 25.05-56.18 69.52-55.95 12.67-.01 46.43 4.13 55.57 15.62 1.35 2.09 2.02 4.55 1.92 7.04v10.11c0 4.44-1.62 6.66-4.87 6.66-7.71-.86-21.39-11.17-49.16-10.75-6.89-.36-39.89.91-38.41 24.97-.43 18.96 26.61 26.07 29.7 26.89 36.46 10.97 48.65 12.79 63.12 29.58 17.14 22.25 7.9 48.3 4.35 55.44-19.08 37.49-68.42 34.44-69.26 34.42zm40.2 104.86c-70.03 51.72-171.69 79.25-258.49 79.25A469.127 469.127 0 0 1 2.83 327.46c-6.53-5.89-.77-13.96 7.17-9.47a637.37 637.37 0 0 0 316.88 84.12 630.22 630.22 0 0 0 241.59-49.55c11.78-5 21.77 7.8 10.12 16.38zm29.19-33.29c-8.96-11.52-59.28-5.38-81.81-2.69-6.79.77-7.94-5.12-1.79-9.47 40.07-28.17 105.88-20.1 113.44-10.63 7.55 9.47-2.05 75.41-39.56 106.91-5.76 4.87-11.27 2.3-8.71-4.1 8.44-21.25 27.39-68.49 18.43-80.02z"/></svg>
|
After Width: | Height: | Size: 2.3 KiB |
1
resources/views/components/icon/brand/oidc.blade.php
Normal file
1
resources/views/components/icon/brand/oidc.blade.php
Normal file
@ -0,0 +1 @@
|
||||
<svg {{ $attributes->merge(['class' => 'icon', 'aria-label' => 'OpenID Connect']) }} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512"><path d="M271.5 432l-68 32C88.5 453.7 0 392.5 0 318.2c0-71.5 82.5-131 191.7-144.3v43c-71.5 12.5-124 53-124 101.3 0 51 58.5 93.3 135.7 103v-340l68-33.2v384zM448 291l-131.3-28.5 36.8-20.7c-19.5-11.5-43.5-20-70-24.8v-43c46.2 5.5 87.7 19.5 120.3 39.3l35-19.8L448 291z"/></svg>
|
After Width: | Height: | Size: 415 B |
@ -72,7 +72,7 @@ Route::post('auth/register', [RegistrationController::class, 'register'])
|
||||
->name('auth.register');
|
||||
|
||||
Route::get('/auth/oauth/{provider}/redirect', [SocialiteController::class, 'redirect'])->name('auth.oauth.redirect');
|
||||
Route::get('/auth/oauth/{provider}/callback', [SocialiteController::class, 'callback'])->name('auth.oauth.callback');
|
||||
Route::any('/auth/oauth/{provider}/callback', [SocialiteController::class, 'callback'])->name('auth.oauth.callback');
|
||||
|
||||
Route::group(['middleware' => 'auth:sanctum'], function () {
|
||||
Route::get('links/feed', [FeedController::class, 'links'])->name('links.feed');
|
||||
|
Loading…
x
Reference in New Issue
Block a user