25 lines
681 B
PHP
25 lines
681 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
require dirname(__DIR__) . '/src/lib.php';
|
|
|
|
start_session();
|
|
|
|
try {
|
|
$cfg = config();
|
|
$state = bin2hex(random_bytes(16));
|
|
$_SESSION['oidc_state'] = $state;
|
|
|
|
$discovery = oidc_discovery();
|
|
redirect($discovery['authorization_endpoint'] . '?' . http_build_query([
|
|
'response_type' => 'code',
|
|
'client_id' => $cfg['client_id'],
|
|
'redirect_uri' => $cfg['redirect_uri'],
|
|
'scope' => 'openid profile email groups',
|
|
'state' => $state,
|
|
]));
|
|
} catch (RuntimeException $e) {
|
|
page_start('Login error');
|
|
echo '<h1>Cannot reach tinyauth</h1><p>' . h($e->getMessage()) . '</p>';
|
|
page_end();
|
|
}
|