openvibers/openvibe.events Commits
Answer an unknown API path with a problem document, not 403 HTML (#196)
Changes
@@@ -132,10 +132,11 @@ server {proxy_set_header X-Forwarded-Proto $scheme;}-- # ── Everything else under /api/: host-local only (see header) ──++ # ── Everything else under /api/: a problem document, never a page; the API stays host-local ──location /api/ {-- return 403;-- # To expose it (token-guarded) to off-host services instead:++ default_type application/problem+json;++ return 404 '{"type":"about:blank","title":"Not Found","status":404,"code":"events.not_found","detail":"No such route on openvibe.events."}';++ # To expose the API (token-guarded) to off-host services instead:# proxy_pass http://127.0.0.1:4300;# proxy_http_version 1.1;# proxy_set_header Host $host;@@@ -266,7 +266,10 @@ t('deploy/nginx/openvibe.events.conf is the API and product origin, with no rediassert.ok(conf.includes(loc), `${loc} is proxied`);}assert.ok(conf.includes('location ~ ^/api/v1/(events|subscriptions|checkpoints)(/|$)'), 'the token-guarded API block');-- assert.ok(conf.includes('location /api/ {'), 'the /api/ refusal block');++ const apiBlock = conf.slice(conf.indexOf('location /api/ {'), conf.indexOf('\n }', conf.indexOf('location /api/ {')));++ assert.ok(apiBlock.includes('default_type application/problem+json;'), 'an unknown API path answers a problem document');++ assert.ok(/return 404 /.test(apiBlock), 'with a 404');++ assert.ok(!/^\s*proxy_pass/m.test(apiBlock), 'the API stays host-local');assert.ok(conf.includes('proxy_buffering off;'), 'SSE is not buffered');assert.ok(conf.includes('proxy_read_timeout 1h;'), 'SSE keeps its long read timeout');const refusals = [conf.indexOf('location ~* ^/metrics(/|$) { return 404; }'), conf.indexOf('location ~* ^/internal(/|$) { return 404; }')];
@@ -132,10 +132,11 @@ server {
@@ -132,10 +132,11 @@ server {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
- # ── Everything else under /api/: host-local only (see header) ──
+ # ── Everything else under /api/: a problem document, never a page; the API stays host-local ──
location /api/ {
location /api/ {
- return 403;
- # To expose it (token-guarded) to off-host services instead:
+ default_type application/problem+json;
+ return 404 '{"type":"about:blank","title":"Not Found","status":404,"code":"events.not_found","detail":"No such route on openvibe.events."}';
+ # To expose the API (token-guarded) to off-host services instead:
# proxy_pass http://127.0.0.1:4300;
# proxy_pass http://127.0.0.1:4300;
# proxy_http_version 1.1;
# proxy_http_version 1.1;
# proxy_set_header Host $host;
# proxy_set_header Host $host;
@@ -266,7 +266,10 @@ t('deploy/nginx/openvibe.events.conf is the API and product origin, with no redi
@@ -266,7 +266,10 @@ t('deploy/nginx/openvibe.events.conf is the API and product origin, with no redi
assert.ok(conf.includes(loc), `${loc} is proxied`);
assert.ok(conf.includes(loc), `${loc} is proxied`);
}
}
assert.ok(conf.includes('location ~ ^/api/v1/(events|subscriptions|checkpoints)(/|$)'), 'the token-guarded API block');
assert.ok(conf.includes('location ~ ^/api/v1/(events|subscriptions|checkpoints)(/|$)'), 'the token-guarded API block');
- assert.ok(conf.includes('location /api/ {'), 'the /api/ refusal block');
+ const apiBlock = conf.slice(conf.indexOf('location /api/ {'), conf.indexOf('\n }', conf.indexOf('location /api/ {')));
+ assert.ok(apiBlock.includes('default_type application/problem+json;'), 'an unknown API path answers a problem document');
+ assert.ok(/return 404 /.test(apiBlock), 'with a 404');
+ assert.ok(!/^\s*proxy_pass/m.test(apiBlock), 'the API stays host-local');
assert.ok(conf.includes('proxy_buffering off;'), 'SSE is not buffered');
assert.ok(conf.includes('proxy_buffering off;'), 'SSE is not buffered');
assert.ok(conf.includes('proxy_read_timeout 1h;'), 'SSE keeps its long read timeout');
assert.ok(conf.includes('proxy_read_timeout 1h;'), 'SSE keeps its long read timeout');
const refusals = [conf.indexOf('location ~* ^/metrics(/|$) { return 404; }'), conf.indexOf('location ~* ^/internal(/|$) { return 404; }')];
const refusals = [conf.indexOf('location ~* ^/metrics(/|$) { return 404; }'), conf.indexOf('location ~* ^/internal(/|$) { return 404; }')];