support basic auth in ETAPI

This commit is contained in:
zadam
2022-10-08 20:59:11 +02:00
parent 6d4ef4ee3d
commit 3e4a9f63fa
4 changed files with 38 additions and 1 deletions

View File

@@ -30,6 +30,20 @@ function parseAuthToken(auth) {
return null;
}
if (auth.startsWith("Basic ")) {
// allow also basic auth format for systems which allow this type of authentication
// expect ETAPI token in the password field, ignore username
// https://github.com/zadam/trilium/issues/3181
const basicAuthStr = utils.fromBase64(auth.substring(6)).toString("UTF-8");
const basicAuthChunks = basicAuthStr.split(":");
if (basicAuthChunks.length === 2) {
auth = basicAuthChunks[1];
} else {
return null;
}
}
const chunks = auth.split("_");
if (chunks.length === 1) {