Skip to content

Commit

Permalink
v5.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
agolybev committed May 22, 2020
2 parents a3b4517 + 998b095 commit e6731c5
Show file tree
Hide file tree
Showing 8 changed files with 74 additions and 14 deletions.
5 changes: 4 additions & 1 deletion Common/config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@
"secretAccessKey": "SECRET",
"useRequestToGetUrl": false,
"useSignedUrl": false,
"sslEnabled": false,
"s3ForcePathStyle": true,
"externalHost": ""
},
"rabbitmq": {
Expand Down Expand Up @@ -114,7 +116,8 @@
"dbPass": "onlyoffice",
"charset": "utf8",
"connectionlimit": 10,
"max_allowed_packet": 1048575
"max_allowed_packet": 1048575,
"pgPoolExtraOptions": {}
},
"redis": {
"name": "redis",
Expand Down
29 changes: 28 additions & 1 deletion Common/sources/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,35 @@
'use strict';

var config = require('config');
var util = require('util');

var log4js = require('log4js');

// https://stackoverflow.com/a/36643588
var dateToJSONWithTZ = function (d) {
var timezoneOffsetInHours = -(d.getTimezoneOffset() / 60); //UTC minus local time
var sign = timezoneOffsetInHours >= 0 ? '+' : '-';
var leadingZero = (Math.abs(timezoneOffsetInHours) < 10) ? '0' : '';

//It's a bit unfortunate that we need to construct a new Date instance
//(we don't want _d_ Date instance to be modified)
var correctedDate = new Date(d.getFullYear(), d.getMonth(),
d.getDate(), d.getHours(), d.getMinutes(), d.getSeconds(),
d.getMilliseconds());
correctedDate.setHours(d.getHours() + timezoneOffsetInHours);
var iso = correctedDate.toISOString().replace('Z', '');
return iso + sign + leadingZero + Math.abs(timezoneOffsetInHours).toString() + ':00';
};

log4js.addLayout('json', function(config) {
return function(logEvent) {
logEvent['startTime'] = dateToJSONWithTZ(logEvent['startTime']);
logEvent['message'] = util.format(...logEvent['data']);
delete logEvent['data'];
return JSON.stringify(logEvent);
}
});

log4js.configure(config.get('log.filePath'));

var logger = log4js.getLogger('nodeJS');
Expand Down Expand Up @@ -67,4 +94,4 @@ exports.fatal = function (){
};
exports.shutdown = function (callback) {
return log4js.shutdown(callback);
};
};
7 changes: 5 additions & 2 deletions Common/sources/storage-s3.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ var cfgSecretAccessKey = configStorage.get('secretAccessKey');
var cfgUseRequestToGetUrl = configStorage.get('useRequestToGetUrl');
var cfgUseSignedUrl = configStorage.get('useSignedUrl');
var cfgExternalHost = configStorage.get('externalHost');
var cfgSslEnabled = configStorage.get('sslEnabled');
var cfgS3ForcePathStyle = configStorage.get('s3ForcePathStyle');
var configFs = configStorage.get('fs');
var cfgStorageUrlExpires = configFs.get('urlExpires');
const cfgExpSessionAbsolute = ms(config.get('services.CoAuthoring.expire.sessionabsolute'));
Expand All @@ -69,9 +71,10 @@ var configS3 = {
accessKeyId: cfgAccessKeyId,
secretAccessKey: cfgSecretAccessKey
};

if (configS3.endpoint) {
configS3.sslEnabled = false;
configS3.s3ForcePathStyle = true;
configS3.sslEnabled = cfgSslEnabled;
configS3.s3ForcePathStyle = cfgS3ForcePathStyle;
}
AWS.config.update(configS3);
var s3Client = new AWS.S3();
Expand Down
21 changes: 16 additions & 5 deletions DocService/sources/DocsCoServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -964,11 +964,14 @@ function checkJwt(docId, token, type) {
}
return res;
}
function checkJwtHeader(docId, req) {
var authorization = req.get(cfgTokenInboxHeader);
if (authorization && authorization.startsWith(cfgTokenInboxPrefix)) {
var token = authorization.substring(cfgTokenInboxPrefix.length);
return checkJwt(docId, token, commonDefines.c_oAscSecretType.Inbox);
function checkJwtHeader(docId, req, opt_header, opt_prefix, opt_secretType) {
let header = opt_header || cfgTokenInboxHeader;
let prefix = opt_prefix || cfgTokenInboxPrefix;
let secretType = opt_secretType || commonDefines.c_oAscSecretType.Inbox;
let authorization = req.get(header);
if (authorization && authorization.startsWith(prefix)) {
var token = authorization.substring(prefix.length);
return checkJwt(docId, token, secretType);
}
return null;
}
Expand Down Expand Up @@ -2405,6 +2408,10 @@ exports.install = function(server, callbackFunction) {
let changesToSend = arrNewDocumentChanges;
if(changesToSend.length > cfgPubSubMaxChanges) {
changesToSend = null;
} else {
changesToSend.forEach((value) => {
value.time = value.time.getTime();
})
}
yield* publish({type: commonDefines.c_oPublishType.changes, docId: docId, userId: userId,
changes: changesToSend, startIndex: startIndex, changesIndex: puckerIndex,
Expand All @@ -2424,6 +2431,10 @@ exports.install = function(server, callbackFunction) {
let changesToSend = arrNewDocumentChanges;
if(changesToSend.length > cfgPubSubMaxChanges) {
changesToSend = null;
} else {
changesToSend.forEach((value) => {
value.time = value.time.getTime();
})
}
let isPublished = yield* publish({type: commonDefines.c_oPublishType.changes, docId: docId, userId: userId,
changes: changesToSend, startIndex: startIndex, changesIndex: puckerIndex,
Expand Down
9 changes: 8 additions & 1 deletion DocService/sources/baseConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,14 @@ UserCallback.prototype.toSQLInsert = function(){
UserCallback.prototype.getCallbackByUserIndex = function(docId, callbacksStr, opt_userIndex) {
logger.debug("getCallbackByUserIndex: docId = %s userIndex = %s callbacks = %s", docId, opt_userIndex, callbacksStr);
if (!callbacksStr || !callbacksStr.startsWith(UserCallback.prototype.delimiter)) {
return callbacksStr;
let index = callbacksStr.indexOf(UserCallback.prototype.delimiter);
if (-1 === index) {
//old format
return callbacksStr;
} else {
//mix of old and new format
callbacksStr = callbacksStr.substring(index);
}
}
let callbacks = callbacksStr.split(UserCallback.prototype.delimiter);
let callbackUrl = "";
Expand Down
7 changes: 6 additions & 1 deletion DocService/sources/fileuploaderservice.js
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,12 @@ exports.uploadImageFile = function(req, res) {
logger.debug('Start uploadImageFile: docId = %s', docId);

if (cfgTokenEnableBrowser) {
var checkJwtRes = checkJwtUpload(docId, 'uploadImageFile', req.query['token']);
let checkJwtRes = docsCoServer.checkJwtHeader(docId, req, 'Authorization', 'Bearer ', commonDefines.c_oAscSecretType.Session);
if (!checkJwtRes) {
//todo remove compatibility with previous versions
checkJwtRes = checkJwtUpload(docId, 'uploadImageFile', req.query['token']);
}

if (!checkJwtRes.err) {
docId = checkJwtRes.docId || docId;
encrypted = checkJwtRes.encrypted;
Expand Down
8 changes: 6 additions & 2 deletions DocService/sources/postgreSqlBaseConnector.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ var co = require('co');
var types = require('pg').types;
var sqlBase = require('./baseConnector');
var configSql = require('config').get('services.CoAuthoring.sql');
var pool = new pg.Pool({
var pgPoolExtraOptions = configSql.get('pgPoolExtraOptions');
let connectionConfig = {
host: configSql.get('dbHost'),
port: configSql.get('dbPort'),
user: configSql.get('dbUser'),
Expand All @@ -47,8 +48,11 @@ var pool = new pg.Pool({
min: 0,
ssl: false,
idleTimeoutMillis: 30000
});
};
Object.assign(connectionConfig, pgPoolExtraOptions);
var pool = new pg.Pool(connectionConfig);
//todo datetime timezone
pg.defaults.parseInputDatesAsUTC = true;
types.setTypeParser(1114, function(stringValue) {
return new Date(stringValue + '+0000');
});
Expand Down
2 changes: 1 addition & 1 deletion run-develop.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def run_integration_example():
start_mac_services()

base.print_info('Build modules')
base.cmd_in_dir('../build_tools', 'python', ['configure.py', '--branch', 'develop', '--module', 'develop', '--update', '1', '--update-light', '1', '--clean', '0', '--sdkjs-addon', 'comparison', '--sdkjs-addon', 'content-controls'])
base.cmd_in_dir('../build_tools', 'python', ['configure.py', '--branch', 'develop', '--module', 'develop', '--update', '1', '--update-light', '1', '--clean', '0', '--sdkjs-addon', 'comparison', '--sdkjs-addon', 'content-controls', '--web-apps-addon', 'mobile'])
base.cmd_in_dir('../build_tools', 'python', ['make.py'])

run_integration_example()
Expand Down

0 comments on commit e6731c5

Please sign in to comment.