- linkedin_auth API: generates auth URL with CSRF state stored in session - linkedin_callback: exchanges code for tokens, writes to project's config.json - index.php: route /linkedin/callback before auth check - Connect button wired up in JS; reads LINKEDIN_CLIENT_ID/SECRET from server env Server setup required: SetEnv LINKEDIN_CLIENT_ID ... SetEnv LINKEDIN_CLIENT_SECRET ... Redirect URI to register in LinkedIn app: https://<host>/linkedin/callback Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
55 lines
1.5 KiB
PHP
55 lines
1.5 KiB
PHP
<?php
|
|
define('ROOT', dirname(__DIR__));
|
|
require ROOT . '/lib/bootstrap.php';
|
|
|
|
$uri = rtrim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/') ?: '/';
|
|
|
|
// Public routes — no auth required
|
|
if ($uri === '/login') {
|
|
if (Auth::check()) { header('Location: /'); exit; }
|
|
include ROOT . '/views/login.php';
|
|
exit;
|
|
}
|
|
if ($uri === '/api/auth') {
|
|
include ROOT . '/web/api/auth.php';
|
|
exit;
|
|
}
|
|
|
|
// LinkedIn OAuth callback — session required but no full auth check
|
|
// (LinkedIn redirects back here; user's browser session is active)
|
|
if ($uri === '/linkedin/callback') {
|
|
include ROOT . '/web/linkedin_callback.php';
|
|
exit;
|
|
}
|
|
|
|
// All other routes require login
|
|
Auth::requireLogin();
|
|
ProjectTypes::load();
|
|
|
|
if ($uri === '/' || $uri === '/dashboard') {
|
|
include ROOT . '/views/dashboard.php';
|
|
|
|
} elseif ($uri === '/settings') {
|
|
include ROOT . '/views/settings.php';
|
|
|
|
} elseif ($uri === '/audit') {
|
|
include ROOT . '/views/audit.php';
|
|
|
|
} elseif (preg_match('#^/project/(\d+)$#', $uri, $m)) {
|
|
$project_id = (int)$m[1];
|
|
include ROOT . '/views/project/view.php';
|
|
|
|
} elseif (preg_match('#^/api/([a-z_]+)#', $uri, $m)) {
|
|
$api_file = ROOT . '/web/api/' . $m[1] . '.php';
|
|
if (file_exists($api_file)) {
|
|
include $api_file;
|
|
} else {
|
|
http_response_code(404);
|
|
header('Content-Type: application/json');
|
|
echo json_encode(['error' => 'API endpoint not found']);
|
|
}
|
|
|
|
} else {
|
|
http_response_code(404);
|
|
include ROOT . '/views/error.php';
|
|
}
|