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
@@ -15,6 +15,17 @@ export function isLoopbackHostname(hostname: string): boolean {
|
||||
return false;
|
||||
}
|
||||
|
||||
/** Empty inbound OneBot tokens are safe when the listener is loopback, or
|
||||
* when the operator opened WebUI on loopback (they can bind 0.0.0.0
|
||||
* without a token on purpose). A remote WebUI plus a public bind host
|
||||
* must keep a token. */
|
||||
export function allowEmptyInboundAccessToken(
|
||||
webuiHostname: string,
|
||||
bindHost: string | undefined,
|
||||
): boolean {
|
||||
return isLoopbackHostname(webuiHostname) || isLoopbackHostname(bindHost ?? '');
|
||||
}
|
||||
|
||||
export function shouldWarnAboutInsecureRemoteAccess(location: {
|
||||
protocol: string;
|
||||
hostname: string;
|
||||
|
||||
Reference in new issue
Block a user