mirror of
https://github.com/zadam/trilium.git
synced 2025-11-07 13:56:11 +01:00
fixed custom header authentication
This commit is contained in:
@@ -79,8 +79,7 @@ function reject(req, res, message) {
|
||||
|
||||
function checkCredentials(req, res, next) {
|
||||
const header = req.headers['trilium-cred'] || '';
|
||||
const token = header.split(/\s+/).pop() || '';
|
||||
const auth = new Buffer.from(token, 'base64').toString();
|
||||
const auth = new Buffer.from(header, 'base64').toString();console.log("auth", auth);
|
||||
const [username, password] = auth.split(/:/);
|
||||
|
||||
const dbUsername = optionService.getOption('username');
|
||||
|
||||
@@ -38,9 +38,7 @@ function exec(opts) {
|
||||
};
|
||||
|
||||
if (opts.auth) {
|
||||
const token = Buffer.from(opts.auth.user + ":" + opts.auth.pass).toString('base64');
|
||||
|
||||
headers['Authorization'] = `Basic ${token}`;
|
||||
headers['trilium-cred'] = Buffer.from(opts.auth.username + ":" + opts.auth.password).toString('base64');
|
||||
}
|
||||
|
||||
const request = client.request({
|
||||
|
||||
@@ -70,9 +70,9 @@ async function setupSyncFromSyncServer(syncServerHost, syncProxy, username, pass
|
||||
const resp = await request.exec({
|
||||
method: 'get',
|
||||
url: syncServerHost + '/api/setup/sync-seed',
|
||||
headers: {
|
||||
// not using Authorization header because some proxy servers will filter it out
|
||||
'trilium-cred': Buffer.from(username + ':' + password).toString('base64')
|
||||
auth: {
|
||||
username,
|
||||
password
|
||||
},
|
||||
proxy: syncProxy,
|
||||
timeout: 30000 // seed request should not take long
|
||||
|
||||
Reference in New Issue
Block a user