Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/syslog-audit-sinks.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'seamless-auth-api': patch
---

Syslog audit sinks are available (#586). Creating or updating a syslog sink no longer returns a 400. Records go over RFC 5424 on TLS with octet counting, and carry `seq` and `hash` in the structured data element `seamless@67592`, under the Fells Code IANA Private Enterprise Number 67592. Key collector parsing rules on that SD-ID.
4 changes: 2 additions & 2 deletions docs/adr/0005-extensibility-callouts.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ Among roles of one kind, sets apply in role-name order, so the last name alphabe
- Credentials are never stored. A sink names env vars ending `_AUDIT_SINK_SECRET`, the same pattern OAuth providers use. A send whose named env var is unset or unusable, or whose settings production does not allow (plain TCP syslog), fails as `misconfigured` before any connection.
- Retention never deletes past the oldest sink cursor, and a disabled sink holds it too (decided 2026-11-07). An audit event deleted before a SIEM receives it cannot be recovered, so a disabled sink holds retention until it is deleted. Retention logs a warning naming the holding sink and saying to delete it to release retention.
- An OTLP 2xx counts as delivered, including one whose `partialSuccess` reports rejected records (decided 2026-11-07). A collector rejects such records for their content, so retrying them would stall the sink forever.
- Syslog records carry `seq` and `hash` in the SD-ID `seamless@32473`. 32473 is the RFC 5612 documentation number, a placeholder until Fells Code has an IANA Private Enterprise Number (#586). A release must not ship with it.
- 0.23.0 ships with OTLP only (decided 2026-11-08). Collectors key their parsing rules on the SD-ID, so shipping the placeholder and changing it later would break those rules. The syslog transport is in the code, but creating or updating a syslog sink is refused with a 400 until 0.23.1 sets the real SD-ID and lifts the refusal (#586).
- Syslog records carry `seq` and `hash` in the SD-ID `seamless@67592`, under the Fells Code IANA Private Enterprise Number 67592 (#586). Collectors key their parsing rules on the SD-ID, so it does not change.
- 0.23.0 shipped with OTLP only (decided 2026-11-08), so no release ever used a placeholder SD-ID. Syslog sinks arrive in 0.23.1 with the real one (#586).

### E8. Every callout follows the same reachability rules

Expand Down
6 changes: 3 additions & 3 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ export does. A sink retries until its collector takes the events, backing off to
reports how far behind the chain head it is. Destinations follow the same rules as webhooks,
including `CALLOUT_PRIVATE_HOSTS`, and plain TCP syslog is refused in production.

Syslog sinks arrive in 0.23.1. Until then the API refuses to create or update one with a 400,
because the syslog records' SD-ID needs the Fells Code IANA enterprise number first (#586). Use an
OTLP sink in the meantime.
Syslog records carry `seq` and `hash` in the structured data element `seamless@67592` (67592 is
the Fells Code IANA Private Enterprise Number). Key collector parsing rules on that SD-ID. Syslog
sinks need API 0.23.1 or later; 0.23.0 refuses them with a 400.

| Variable | Required | Default | Notes |
| -------------------------- | -------- | ------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
Expand Down
2 changes: 1 addition & 1 deletion openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -10391,7 +10391,7 @@
},
"post": {
"summary": "Create an audit sink",
"description": "Starts after the newest event unless `startAfterSeq` replays from an earlier one. Credentials are named as `_AUDIT_SINK_SECRET` env vars, never stored. A syslog sink is refused with a 400 until 0.23.1.",
"description": "Starts after the newest event unless `startAfterSeq` replays from an earlier one. Credentials are named as `_AUDIT_SINK_SECRET` env vars, never stored.",
"tags": ["Admin", "Audit sinks"],
"security": [{ "bearerAuth": [] }],
"requestBody": {
Expand Down
2 changes: 1 addition & 1 deletion src/generated/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9838,7 +9838,7 @@ export interface paths {
put?: never;
/**
* Create an audit sink
* @description Starts after the newest event unless `startAfterSeq` replays from an earlier one. Credentials are named as `_AUDIT_SINK_SECRET` env vars, never stored. A syslog sink is refused with a 400 until 0.23.1.
* @description Starts after the newest event unless `startAfterSeq` replays from an earlier one. Credentials are named as `_AUDIT_SINK_SECRET` env vars, never stored.
*/
post: {
parameters: {
Expand Down
17 changes: 3 additions & 14 deletions src/lib/auditSinkTransport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,21 +33,10 @@ const MAX_RESPONSE_BYTES = 64 * 1024;

/**
* The structured data element carrying `seq` and `hash` in each syslog record. RFC 5424 needs
* a private SD-ID to be `name@<IANA enterprise number>`. 32473 is the number RFC 5612 reserves
* for documentation, a placeholder until Fells Code has its own.
* a private SD-ID to be `name@<IANA enterprise number>`, and 67592 is the Fells Code number.
* Collectors key their parsing rules on it, so changing it is a breaking change.
*/
// TODO(#586): replace 32473 with the Fells Code IANA enterprise number before release.
export const SYSLOG_SD_ID = 'seamless@32473';

/**
* Collectors key their parsing rules on the SD-ID, so changing it once adopters have written
* those rules is a breaking change. Syslog sinks stay refused until the real number is in.
*/
// TODO(#586): set to true in 0.23.1 together with the real SD-ID.
export const SYSLOG_SINKS_AVAILABLE = false;

export const SYSLOG_UNAVAILABLE =
'Syslog audit sinks are not available in this release; they arrive in Seamless Auth 0.23.1. Use an OTLP sink until then.';
export const SYSLOG_SD_ID = 'seamless@67592';

export const AUDIT_SINK_SCOPE = 'seamless-auth.audit';

Expand Down
2 changes: 1 addition & 1 deletion src/routes/auditSinks.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ router.post(
...write,
summary: 'Create an audit sink',
description:
'Starts after the newest event unless `startAfterSeq` replays from an earlier one. Credentials are named as `_AUDIT_SINK_SECRET` env vars, never stored. A syslog sink is refused with a 400 until 0.23.1.',
'Starts after the newest event unless `startAfterSeq` replays from an earlier one. Credentials are named as `_AUDIT_SINK_SECRET` env vars, never stored.',
schemas: {
body: CreateAuditSinkRequestSchema,
response: { 201: AuditSinkResponseSchema, 400: ErrorSchema, 403: StepUpRequiredErrorSchema },
Expand Down
5 changes: 0 additions & 5 deletions src/services/auditSinkService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import {
eventRecord,
sendToSink,
sinkDestinationProblem,
SYSLOG_SINKS_AVAILABLE,
SYSLOG_UNAVAILABLE,
testRecord,
} from '../lib/auditSinkTransport.js';
import { AuditSink } from '../models/auditSinks.js';
Expand Down Expand Up @@ -86,9 +84,6 @@ export function serializeSink(sink: AuditSink, head: number) {
}

function assertSettings(settings: AuditSinkSettings) {
if (settings.kind === 'syslog' && !SYSLOG_SINKS_AVAILABLE) {
throw new AuditSinkError(400, SYSLOG_UNAVAILABLE);
}
const problem = sinkDestinationProblem(settings);
if (problem) throw new AuditSinkError(400, problem);
}
Expand Down
31 changes: 2 additions & 29 deletions tests/integration/admin/auditSinks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Application } from 'express';
import request from 'supertest';
import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';

const { query, gate } = vi.hoisted(() => ({ query: vi.fn(), gate: { syslog: false } }));
const { query } = vi.hoisted(() => ({ query: vi.fn() }));

vi.mock('../../../src/models/index.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('../../../src/models/index.js')>();
Expand All @@ -14,14 +14,11 @@ vi.mock('../../../src/lib/auditSinkTransport.js', async (importOriginal) => {
return {
...actual,
sendToSink: vi.fn(),
get SYSLOG_SINKS_AVAILABLE() {
return gate.syslog;
},
};
});

import { createApp } from '../../../src/app';
import { sendToSink, SYSLOG_UNAVAILABLE } from '../../../src/lib/auditSinkTransport.js';
import { sendToSink } from '../../../src/lib/auditSinkTransport.js';
import { AuditSink } from '../../../src/models/auditSinks.js';
import { Session } from '../../../src/models/sessions.js';
import { AuthEventService } from '../../../src/services/authEventService.js';
Expand Down Expand Up @@ -68,7 +65,6 @@ beforeAll(async () => {

beforeEach(() => {
vi.clearAllMocks();
gate.syslog = false;
(Session.findOne as any).mockResolvedValue(buildFreshStepUpSession());
query.mockResolvedValue([{ head: '42', oldest: '1' }]);
});
Expand Down Expand Up @@ -118,29 +114,7 @@ describe('audit sinks', () => {
expect(AuditSink.create).not.toHaveBeenCalled();
});

it('refuses a syslog sink until its SD-ID is registered', async () => {
const created = await request(app)
.post('/admin/audit-sinks')
.send({ name: 'SIEM', settings: { kind: 'syslog', host: 'collector.example.com' } });

expect(created.status).toBe(400);
expect(created.body.error).toBe(SYSLOG_UNAVAILABLE);
expect(AuditSink.create).not.toHaveBeenCalled();

const record = buildSink();
vi.mocked(AuditSink.findByPk).mockResolvedValue(record);

const updated = await request(app)
.patch(`/admin/audit-sinks/${sinkId}`)
.send({ settings: { kind: 'syslog', host: 'collector.example.com' } });

expect(updated.status).toBe(400);
expect(updated.body.error).toBe(SYSLOG_UNAVAILABLE);
expect(record.update).not.toHaveBeenCalled();
});

it('refuses plain TCP syslog in production', async () => {
gate.syslog = true;
vi.stubEnv('NODE_ENV', 'production');

const res = await request(app)
Expand All @@ -167,7 +141,6 @@ describe('audit sinks', () => {
});

it('reads, updates and deletes a sink, auditing each write', async () => {
gate.syslog = true;
const record = buildSink();
vi.mocked(AuditSink.findByPk).mockResolvedValue(record);

Expand Down
8 changes: 1 addition & 7 deletions tests/postgres/auditSinks.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ import {
import { tmpdir } from 'node:os';
import { join } from 'node:path';

import { afterAll, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest';

// The syslog transport stays tested end to end while the API refuses new syslog sinks (#586).
vi.mock('../../src/lib/auditSinkTransport.js', async (importOriginal) => ({
...(await importOriginal<typeof import('../../src/lib/auditSinkTransport.js')>()),
SYSLOG_SINKS_AVAILABLE: true,
}));
import { afterAll, beforeAll, beforeEach, describe, expect, it } from 'vitest';

import { AuditSink } from '../../src/models/auditSinks.js';
import { getSequelize, initializeModels } from '../../src/models/index.js';
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/lib/auditSinkTransport.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ describe('syslog', () => {
it('marks the test record with its own MSGID and no chain fields', () => {
const message = syslogMessage(testRecord('sink-1'), syslog(1), 'host');

expect(message).toMatch(/^<86>1 \S+ host seamless-auth - test \[seamless@32473 test="true"\] /);
expect(message).toMatch(/^<86>1 \S+ host seamless-auth - test \[seamless@67592 test="true"\] /);
expect(message).not.toContain('seq=');
});

Expand Down
16 changes: 2 additions & 14 deletions tests/unit/services/auditSinkService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,10 @@ import type { AddressInfo } from 'node:net';

import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';

const { query, transaction, gate } = vi.hoisted(() => {
const { query, transaction } = vi.hoisted(() => {
const query = vi.fn();
const transaction = vi.fn(async (fn: (t: unknown) => unknown) => fn({ id: 'tx' }));
return { query, transaction, gate: { syslog: false } };
});

vi.mock('../../../src/lib/auditSinkTransport.js', async (importOriginal) => {
const actual = await importOriginal<typeof import('../../../src/lib/auditSinkTransport.js')>();
return {
...actual,
get SYSLOG_SINKS_AVAILABLE() {
return gate.syslog;
},
};
return { query, transaction };
});

vi.mock('../../../src/models/index.js', () => ({
Expand Down Expand Up @@ -55,7 +45,6 @@ let bodies: string[];
let status: number;

beforeEach(async () => {
gate.syslog = false;
bodies = [];
status = 200;
transaction.mockImplementation(async (fn: (t: unknown) => unknown) => fn({ id: 'tx' }));
Expand Down Expand Up @@ -222,7 +211,6 @@ describe('sinks', () => {
});

it('updates fields and clears the backoff, keeping the cursor', async () => {
gate.syslog = true;
const record = sink({ failureCount: 4, nextAttemptAt: new Date(Date.now() + 60_000) });
vi.mocked(AuditSink.findByPk).mockResolvedValue(record);

Expand Down
Loading