39 lines
2.1 KiB
PHP
39 lines
2.1 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
// authentik-Anmeldung: Knopf auf der Anmeldeseite, Start und Rückkehr des OpenID-Connect-Ablaufs, Einstellungsseite für Administratoren.
|
|
if (!function_exists('plugin_register_login')) {
|
|
return; // älterer DeskHub-Server ohne Anmelde-Erweiterung (Server 1.0.51 oder neuer nötig)
|
|
}
|
|
require_once __DIR__ . '/lib.php';
|
|
|
|
/** Kleines Symbol vor der Beschriftung des Anmelde-Knopfes (icon.svg, als Daten-Adresse: braucht keine eigene Datei-Adresse). */
|
|
function authentik_button_icon(): string
|
|
{
|
|
static $html = null;
|
|
if ($html === null) {
|
|
$svg = @file_get_contents(__DIR__ . '/icon.svg');
|
|
$html = $svg ? '<img src="data:image/svg+xml;base64,' . base64_encode($svg) . '" alt="" width="20" height="20" style="vertical-align:-5px;margin-right:8px;border-radius:5px">' : '';
|
|
}
|
|
return $html;
|
|
}
|
|
|
|
plugin_register_menu('authentik', 'einstellungen', null, 'admin');
|
|
plugin_register_menu('Mein authentik-Konto', 'konto'); // für alle Mitarbeiter: das eigene Konto verknüpfen
|
|
plugin_register_login('start', 'authentik_login_start');
|
|
plugin_register_login('link', 'authentik_link_start', true);
|
|
plugin_register_login('callback', 'authentik_login_callback', true); // gleiche Rückkehr-Adresse für Anmelden und Verknüpfen
|
|
if (function_exists('plugin_register_customer_login')) { // Server 1.0.52 oder neuer
|
|
plugin_register_customer_login('start', 'authentik_customer_start');
|
|
plugin_add_filter('customer.login.buttons', function ($html) {
|
|
if (!authentik_customer_ready()) return $html;
|
|
$cfg = authentik_config();
|
|
return $html . '<a class="btn secondary" style="display:block;text-align:center" href="' . e(plugin_customer_login_url(AUTHENTIK, 'start')) . '">' . authentik_button_icon() . e($cfg['label']) . '</a>';
|
|
});
|
|
}
|
|
plugin_add_filter('staff.login.buttons', function ($html) {
|
|
if (!authentik_ready()) return $html;
|
|
$cfg = authentik_config();
|
|
return $html . '<a class="btn secondary" style="display:block;text-align:center" href="' . e(plugin_login_url(AUTHENTIK, 'start')) . '">' . authentik_button_icon() . e($cfg['label']) . '</a>';
|
|
});
|