| 1 | <?php |
| 2 | declare(strict_types=1); |
| 3 | require __DIR__.'/lib/bootstrap.php'; |
| 4 | try { |
| 5 | $cfg = config(); |
| 6 | if (($cfg['client_id'] ?? '') === '' || ($cfg['client_secret'] ?? '') === '') { |
| 7 | throw new RuntimeException('Productie-login heeft een geregistreerde client-id en een geheim nodig. Zie README.md.'); |
| 8 | } |
| 9 | $_SESSION['oauth_state'] = bin2hex(random_bytes(32)); |
| 10 | $_SESSION['oauth_started'] = time(); |
| 11 | header('Location: https://auth.timfalken.com/oauth/authorize?'.http_build_query([ |
| 12 | 'client_id' => $cfg['client_id'], |
| 13 | 'redirect_uri' => baseUrl().'/callback.php', |
| 14 | 'response_type' => 'code', |
| 15 | 'state' => $_SESSION['oauth_state'], |
| 16 | ])); |
| 17 | } catch (Throwable $e) { |
| 18 | http_response_code(503); |
| 19 | echo htmlspecialchars($e->getMessage()); |
| 20 | } |
projects-timfalken-com verhalenboek