Implements Single Sign-On with Authentik alongside the existing password login. Admins configure Client ID, Client Secret and Base URL directly in the app; the SSO button on the login page only appears when the configuration is complete and enabled. - SsoSetting model + migration (one-row config table) - sso_provider_id / is_sso_user fields on users (migration) - SsoController: redirect to Authentik + callback (token exchange, userinfo fetch, auto-create unknown users) - Admin\SsoSettingController + admin/sso/show view with setup guide and one-click Redirect URI copy - Admin dropdown: SSO-Konfiguration entry - Login page: Authentik button rendered conditionally No additional Composer packages required. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
54 lines
1.1 KiB
PHP
54 lines
1.1 KiB
PHP
<?php
|
|
|
|
namespace App\Models;
|
|
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class SsoSetting extends Model
|
|
{
|
|
protected $table = 'sso_settings';
|
|
|
|
protected $fillable = [
|
|
'base_url',
|
|
'client_id',
|
|
'client_secret',
|
|
'slug',
|
|
'enabled',
|
|
];
|
|
|
|
protected function casts(): array
|
|
{
|
|
return [
|
|
'enabled' => 'boolean',
|
|
];
|
|
}
|
|
|
|
public static function get(): self
|
|
{
|
|
return static::firstOrCreate([]);
|
|
}
|
|
|
|
public function isConfigured(): bool
|
|
{
|
|
return $this->enabled
|
|
&& !empty($this->base_url)
|
|
&& !empty($this->client_id)
|
|
&& !empty($this->client_secret);
|
|
}
|
|
|
|
public function authorizeUrl(): string
|
|
{
|
|
return rtrim($this->base_url, '/') . '/application/o/authorize/';
|
|
}
|
|
|
|
public function tokenUrl(): string
|
|
{
|
|
return rtrim($this->base_url, '/') . '/application/o/token/';
|
|
}
|
|
|
|
public function userInfoUrl(): string
|
|
{
|
|
return rtrim($this->base_url, '/') . '/application/o/userinfo/';
|
|
}
|
|
}
|