Only trust Authelia identity headers from TRUSTED_PROXIES
Security / JS Security (npm audit) (push) Failing after 17s
Lint / JS (eslint) (push) Successful in 18s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Lint / JS (eslint) (pull_request) Successful in 18s
Test / JS Tests (jest) (push) Successful in 20s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / JS Security (npm audit) (pull_request) Failing after 17s
Test / JS Tests (jest) (pull_request) Successful in 17s
Security / JS Security (npm audit) (push) Failing after 17s
Lint / JS (eslint) (push) Successful in 18s
Lint / Notify on failure (push) Skipped
Lint / Deploy (push) Skipped
Lint / JS (eslint) (pull_request) Successful in 18s
Test / JS Tests (jest) (push) Successful in 20s
Lint / Notify on failure (pull_request) Skipped
Lint / Deploy (pull_request) Skipped
Security / JS Security (npm audit) (pull_request) Failing after 17s
Test / JS Tests (jest) (pull_request) Successful in 17s
authenticateSSO and authenticatePage took the user and groups straight from the Remote-* headers, and the server listens on every interface, so any LAN host could connect directly, claim any user and group, and run commands on the workers. It could also write whatever it claimed into the users table. Add TRUSTED_PROXIES (addresses or CIDR ranges) and ignore the identity headers unless the TCP peer is on the list. The peer address is used rather than a forwarding header, which a client could forge. It fails closed: unset means no SSO login succeeds, with a startup warning. Rejected attempts are logged with their source. Worker and Gandalf API-key routes are unchanged. Closes #37 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
dc47e335aa
commit
e302234187
4 files changed
+256
-17
No files matched your search
@@ -13,7 +13,7 @@ require('dotenv').config();
|
||||
const { validateWebhookUrl, applyParams, evalCondition, calculateNextRun } = require('./lib/utils');
|
||||
const { PAGES } = require('./lib/nav');
|
||||
const { renderPage, renderError } = require('./lib/render');
|
||||
const { upsertUser, makeAuthenticatePage } = require('./lib/pageauth');
|
||||
const { upsertUser, makeAuthenticatePage, ssoIdentity, trustedProxies } = require('./lib/pageauth');
|
||||
|
||||
const app = express();
|
||||
const server = http.createServer(app);
|
||||
@@ -676,21 +676,19 @@ async function fireWebhook(executionId, status) {
|
||||
|
||||
// Authelia SSO Middleware
|
||||
async function authenticateSSO(req, res, next) {
|
||||
// Check for Authelia headers
|
||||
const remoteUser = req.headers['remote-user'];
|
||||
const remoteName = req.headers['remote-name'];
|
||||
const remoteEmail = req.headers['remote-email'];
|
||||
const remoteGroups = req.headers['remote-groups'];
|
||||
// Authelia headers, only honoured from TRUSTED_PROXIES (see lib/pageauth.js)
|
||||
const identity = ssoIdentity(req);
|
||||
|
||||
if (!remoteUser) {
|
||||
return res.status(401).json({
|
||||
if (!identity) {
|
||||
return res.status(401).json({
|
||||
error: 'Not authenticated',
|
||||
message: 'Please access this service through auth.lotusguild.org'
|
||||
});
|
||||
}
|
||||
|
||||
const { username: remoteUser, name: remoteName, email: remoteEmail, groups } = identity;
|
||||
|
||||
// Check if user is in allowed groups (admin or employee)
|
||||
const groups = remoteGroups ? remoteGroups.split(',').map(g => g.trim()) : [];
|
||||
const allowedGroups = ['admin', 'employee'];
|
||||
const hasAccess = groups.some(g => allowedGroups.includes(g));
|
||||
|
||||
@@ -1843,6 +1841,13 @@ initDatabase().then(() => {
|
||||
console.log(`PULSE Server running on http://${HOST}:${PORT}`);
|
||||
console.log(`Connected to MariaDB at ${process.env.DB_HOST}`);
|
||||
console.log(`Authentication: Authelia SSO`);
|
||||
const trustedCount = trustedProxies().count;
|
||||
if (trustedCount) {
|
||||
console.log(`Trusted proxies for SSO headers: ${trustedCount}`);
|
||||
} else {
|
||||
console.warn('WARNING: TRUSTED_PROXIES is not set, so no SSO login can succeed. ' +
|
||||
'Set it to the reverse proxy address(es) that run Authelia forward auth.');
|
||||
}
|
||||
console.log(`Worker API Key configured: ${process.env.WORKER_API_KEY ? 'Yes' : 'No'}`);
|
||||
if (DEV_READONLY) {
|
||||
console.warn('************************************************************');
|
||||
|
||||
Reference in new issue
Block a user