revert accidentally committed auth changes, #1629

This commit is contained in:
zadam 2021-02-11 23:04:42 +01:00
parent 067ca9ab16
commit 5b679930de
3 changed files with 7 additions and 7 deletions

View File

@ -224,7 +224,7 @@ function register(app) {
route(GET, '/api/setup/status', [], setupApiRoute.getStatus, apiResultHandler);
route(POST, '/api/setup/new-document', [auth.checkAppNotInitialized], setupApiRoute.setupNewDocument, apiResultHandler);
route(POST, '/api/setup/sync-from-server', [auth.checkAppNotInitialized], setupApiRoute.setupSyncFromServer, apiResultHandler, false);
route(GET, '/api/setup/sync-seed', [auth.checkCredentials], setupApiRoute.getSyncSeed, apiResultHandler);
route(GET, '/api/setup/sync-seed', [auth.checkBasicAuth], setupApiRoute.getSyncSeed, apiResultHandler);
route(POST, '/api/setup/sync-seed', [auth.checkAppNotInitialized], setupApiRoute.saveSyncSeed, apiResultHandler, false);
apiRoute(GET, '/api/sql/schema', sqlRoute.getSchema);

View File

@ -77,8 +77,8 @@ function reject(req, res, message) {
res.status(401).send(message);
}
function checkCredentials(req, res, next) {
const header = req.headers['trilium-cred'] || '';
function checkBasicAuth(req, res, next) {
const header = req.headers.authorization || '';
const token = header.split(/\s+/).pop() || '';
const auth = new Buffer.from(token, 'base64').toString();
const [username, password] = auth.split(/:/);
@ -100,5 +100,5 @@ module.exports = {
checkAppNotInitialized,
checkApiAuthOrElectron,
checkToken,
checkCredentials
checkBasicAuth
};

View File

@ -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: {
'user': username,
'pass': password
},
proxy: syncProxy,
timeout: 30000 // seed request should not take long