fix(webui): allow empty OneBot tokens on loopback bind hosts
Empty inbound tokens were gated on the WebUI page hostname / client IP, so a remote panel visit blocked clearing the token even when the listener was 127.0.0.1. Trust the bind host as well: loopback listeners are not reachable from outside, while 0.0.0.0 still requires a local WebUI session.
This commit is contained in:
7 files changed
+76
-12
No files matched your search
@@ -1,5 +1,6 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import {
|
||||
allowEmptyInboundAccessToken,
|
||||
isLoopbackHostname,
|
||||
shouldWarnAboutInsecureRemoteAccess,
|
||||
} from '../src/lib/transport-security';
|
||||
@@ -27,6 +28,18 @@ describe('WebUI transport security notice', () => {
|
||||
expect(isLoopbackHostname(hostname)).toBe(false);
|
||||
});
|
||||
|
||||
it('allows an empty inbound token when the bind host is loopback, even from a remote WebUI', () => {
|
||||
expect(allowEmptyInboundAccessToken('192.168.1.20', '127.0.0.1')).toBe(true);
|
||||
expect(allowEmptyInboundAccessToken('panel.example.com', 'localhost')).toBe(true);
|
||||
expect(allowEmptyInboundAccessToken('192.168.1.20', '0.0.0.0')).toBe(false);
|
||||
expect(allowEmptyInboundAccessToken('192.168.1.20', '')).toBe(false);
|
||||
});
|
||||
|
||||
it('still allows an empty inbound token when the WebUI itself is opened on loopback', () => {
|
||||
expect(allowEmptyInboundAccessToken('127.0.0.1', '0.0.0.0')).toBe(true);
|
||||
expect(allowEmptyInboundAccessToken('localhost', undefined)).toBe(true);
|
||||
});
|
||||
|
||||
it('warns only when a non-loopback page is accessed without HTTPS', () => {
|
||||
expect(shouldWarnAboutInsecureRemoteAccess({ protocol: 'http:', hostname: '192.168.1.20' }))
|
||||
.toBe(true);
|
||||
|
||||
Reference in new issue
Block a user