Fix crash when CPE sends invalid auth header
This commit is contained in:
1 parent
8b27794cc7
commit
6c37e88ab1
2 files changed
+8
No files matched your search
@@ -169,9 +169,13 @@ export async function httpConnectionRequest(
|
|||||||
if (res.statusCode === 503) return "Device is offline";
|
if (res.statusCode === 503) return "Device is offline";
|
||||||
|
|
||||||
if (res.statusCode === 401 && res.headers["www-authenticate"]) {
|
if (res.statusCode === 401 && res.headers["www-authenticate"]) {
|
||||||
|
try {
|
||||||
authHeader = auth.parseWwwAuthenticateHeader(
|
authHeader = auth.parseWwwAuthenticateHeader(
|
||||||
res.headers["www-authenticate"]
|
res.headers["www-authenticate"]
|
||||||
);
|
);
|
||||||
|
} catch (err) {
|
||||||
|
return "Connection request error: Error parsing www-authenticate header";
|
||||||
|
}
|
||||||
[username, password, authExp] = await extractAuth(authExp, false);
|
[username, password, authExp] = await extractAuth(authExp, false);
|
||||||
} else {
|
} else {
|
||||||
return `Connection request error: Unexpected status code ${res.statusCode}`;
|
return `Connection request error: Unexpected status code ${res.statusCode}`;
|
||||||
|
|||||||
@@ -84,9 +84,13 @@ async function authenticate(
|
|||||||
let authentication;
|
let authentication;
|
||||||
|
|
||||||
if (sessionContext.httpRequest.headers["authorization"]) {
|
if (sessionContext.httpRequest.headers["authorization"]) {
|
||||||
|
try {
|
||||||
authentication = auth.parseAuthorizationHeader(
|
authentication = auth.parseAuthorizationHeader(
|
||||||
sessionContext.httpRequest.headers["authorization"]
|
sessionContext.httpRequest.headers["authorization"]
|
||||||
);
|
);
|
||||||
|
} catch (err) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (authentication && authentication.method === "Digest") {
|
if (authentication && authentication.method === "Digest") {
|
||||||
|
|||||||
Reference in new issue
Block a user