Bound unauthenticated sign-in requests and require active sessions for browser-served account images. Keep live updates authenticated without exposing session material in request URLs, and apply conservative response protections without restricting existing WebUI assets.
20 lines
796 B
TypeScript
20 lines
796 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { extractBearerToken } from '../src/webui/request-security';
|
|
|
|
describe('WebUI stream authentication', () => {
|
|
it('accepts bearer credentials for every live stream', () => {
|
|
for (const path of ['/api/logs/stream', '/api/debug/stream', '/api/state/stream']) {
|
|
const request = new Request(`http://localhost${path}`, {
|
|
headers: { authorization: 'Bearer stream-token' },
|
|
});
|
|
expect(extractBearerToken(request)).toBe('stream-token');
|
|
}
|
|
});
|
|
|
|
it('does not accept tokens from stream query parameters', () => {
|
|
for (const path of ['/api/logs/stream', '/api/debug/stream', '/api/state/stream']) {
|
|
expect(extractBearerToken(new Request(`http://localhost${path}?token=leaked`))).toBe('');
|
|
}
|
|
});
|
|
});
|