diff --git a/Common/config/default.json b/Common/config/default.json index 7d5ac86c..1bd190c9 100644 --- a/Common/config/default.json +++ b/Common/config/default.json @@ -30,8 +30,6 @@ "urlExpires": 604800, "accessKeyId": "AKID", "secretAccessKey": "SECRET", - "useRequestToGetUrl": true, - "useSignedUrl": false, "sslEnabled": false, "s3ForcePathStyle": true, "externalHost": "" diff --git a/Common/npm-shrinkwrap.json b/Common/npm-shrinkwrap.json index aa36da4f..8e4c3f1f 100644 --- a/Common/npm-shrinkwrap.json +++ b/Common/npm-shrinkwrap.json @@ -15,10 +15,6 @@ "json-schema-traverse": "^0.3.0" } }, - "amazon-s3-url-signer": { - "version": "https://github.com/agolybev/amazon-s3-url-signer/archive/v0.0.9.tar.gz", - "integrity": "sha512-wkmsZG000+d711di1U3690g3rE++ettaLZWDrAESgNhklr3wQcYEdEqAnQjgNirM0jjByQ9HTCeV48wFpHHguQ==" - }, "amqplib": { "version": "0.5.2", "resolved": "https://registry.npmjs.org/amqplib/-/amqplib-0.5.2.tgz", diff --git a/Common/package.json b/Common/package.json index 7c29ad73..fda71daa 100644 --- a/Common/package.json +++ b/Common/package.json @@ -4,7 +4,6 @@ "homepage": "https://www.onlyoffice.com", "private": true, "dependencies": { - "amazon-s3-url-signer": "https://github.com/agolybev/amazon-s3-url-signer/archive/v0.0.9.tar.gz", "amqplib": "^0.5.2", "aws-sdk": "^2.346.0", "co": "^4.6.0", diff --git a/Common/sources/storage-s3.js b/Common/sources/storage-s3.js index 7f085def..5acaf5e8 100644 --- a/Common/sources/storage-s3.js +++ b/Common/sources/storage-s3.js @@ -49,8 +49,6 @@ var cfgBucketName = configStorage.get('bucketName'); var cfgStorageFolderName = configStorage.get('storageFolderName'); var cfgAccessKeyId = configStorage.get('accessKeyId'); var cfgSecretAccessKey = configStorage.get('secretAccessKey'); -var cfgUseRequestToGetUrl = configStorage.get('useRequestToGetUrl'); -var cfgUseSignedUrl = configStorage.get('useSignedUrl'); var cfgSslEnabled = configStorage.get('sslEnabled'); var cfgS3ForcePathStyle = configStorage.get('s3ForcePathStyle'); var configFs = configStorage.get('fs'); @@ -227,47 +225,16 @@ exports.getSignedUrl = function(baseUrl, strPath, urlType, optFilename, opt_crea var expires = (commonDefines.c_oAscUrlTypes.Session === urlType ? cfgExpSessionAbsolute / 1000 : cfgStorageUrlExpires) || 31536000; var userFriendlyName = optFilename ? optFilename.replace(/\//g, "%2f") : path.basename(strPath); var contentDisposition = utils.getContentDisposition(userFriendlyName, null, null); - if (cfgUseRequestToGetUrl) { - //default Expires 900 seconds - var params = { - Bucket: cfgBucketName, Key: getFilePath(strPath), ResponseContentDisposition: contentDisposition, Expires: expires - }; - s3Client.getSignedUrl('getObject', params, function(err, data) { - if (err) { - reject(err); - } else { - resolve(utils.changeOnlyOfficeUrl(data, strPath, optFilename)); - } - }); - } else { - var host; - if (cfgRegion) { - host = 'https://s3-'+cfgRegion+'.amazonaws.com'; - } else if (cfgEndpointParsed && - (cfgEndpointParsed.hostname == 'localhost' || cfgEndpointParsed.hostname == '127.0.0.1') && - 80 == cfgEndpointParsed.port) { - host = utils.checkBaseUrl(baseUrl) + cfgEndpointParsed.path; + //default Expires 900 seconds + var params = { + Bucket: cfgBucketName, Key: getFilePath(strPath), ResponseContentDisposition: contentDisposition, Expires: expires + }; + s3Client.getSignedUrl('getObject', params, function(err, data) { + if (err) { + reject(err); } else { - host = cfgEndpoint; + resolve(utils.changeOnlyOfficeUrl(data, strPath, optFilename)); } - if (host && host.length > 0 && '/' != host[host.length - 1]) { - host += '/'; - } - var newUrl; - if (cfgUseSignedUrl) { - //todo уйти от parse - var hostParsed = url.parse(host); - var protocol = hostParsed.protocol.substring(0, hostParsed.protocol.length - 1); - var signerOptions = { - host: hostParsed.hostname, port: hostParsed.port, - protocol: protocol, useSubdomain: false - }; - var awsUrlSigner = s3urlSigner.urlSigner(cfgAccessKeyId, cfgSecretAccessKey, signerOptions); - newUrl = awsUrlSigner.getUrl('GET', getFilePath(strPath), cfgBucketName, expires, contentDisposition); - } else { - newUrl = host + cfgBucketName + '/' + cfgStorageFolderName + '/' + strPath; - } - resolve(utils.changeOnlyOfficeUrl(newUrl, strPath, optFilename)); - } + }); }); };