Merge pull request #21660 from overleaf/jpa-s3-https

[object-persistor] s3: simplify using a custom CA for HTTPS endpoints

GitOrigin-RevId: 2c6a5312a842582e5e40e917ccc586392087cb7a
This commit is contained in:
Jakob Ackermann
2024-11-08 09:07:00 +00:00
committed by Copybot
parent 65dc6bf940
commit 122d89a831
5 changed files with 18 additions and 34 deletions
-1
View File
@@ -36,7 +36,6 @@
},
"devDependencies": {
"@google-cloud/storage": "^6.10.1",
"aws-sdk": "^2.718.0",
"chai": "^4.3.6",
"chai-as-promised": "^7.1.1",
"mocha": "^10.2.0",
@@ -7,7 +7,6 @@ const Path = require('path')
const FilestoreApp = require('./FilestoreApp')
const TestHelper = require('./TestHelper')
const fetch = require('node-fetch')
const S3 = require('aws-sdk/clients/s3')
const { promisify } = require('util')
const { Storage } = require('@google-cloud/storage')
const streamifier = require('streamifier')
@@ -43,6 +42,7 @@ const {
PerProjectEncryptedS3Persistor,
RootKeyEncryptionKey,
} = require('@overleaf/object-persistor/src/PerProjectEncryptedS3Persistor')
const { S3Persistor } = require('@overleaf/object-persistor/src/S3Persistor')
const crypto = require('crypto')
describe('Filestore', function () {
@@ -521,18 +521,11 @@ describe('Filestore', function () {
bucketName = `random-bucket-${new ObjectId().toString()}`
fileUrl = `${filestoreUrl}/bucket/${bucketName}/key/${fileId}`
const cfg = s3Config()
const s3ClientSettings = {
credentials: {
accessKeyId: process.env.MINIO_ROOT_USER,
secretAccessKey: process.env.MINIO_ROOT_PASSWORD,
},
endpoint: cfg.endpoint,
httpOptions: cfg.httpOptions,
s3ForcePathStyle: cfg.pathStyle,
}
const s3 = new S3(s3ClientSettings)
const s3 = new S3Persistor({
...s3Config(),
key: process.env.MINIO_ROOT_USER,
secret: process.env.MINIO_ROOT_PASSWORD,
})._getClientForBucket(bucketName)
await s3
.createBucket({
Bucket: bucketName,
@@ -1263,16 +1256,8 @@ describe('Filestore', function () {
})
let s3Client
before('create s3Client', function () {
const cfg = s3Config()
const s3ClientSettings = {
accessKeyId: cfg.key,
secretAccessKey: cfg.secret,
endpoint: cfg.endpoint,
httpOptions: cfg.httpOptions,
s3ForcePathStyle: cfg.pathStyle,
}
s3Client = new S3(s3ClientSettings)
before('create s3 client', function () {
s3Client = new S3Persistor(s3Config())._getClientForBucket('')
})
async function checkDEKStorage({
@@ -1,7 +1,6 @@
const fs = require('fs')
const Path = require('path')
const crypto = require('crypto')
const https = require('https')
const {
RootKeyEncryptionKey,
} = require('@overleaf/object-persistor/src/PerProjectEncryptedS3Persistor')
@@ -12,12 +11,7 @@ function s3BaseConfig() {
endpoint: process.env.AWS_S3_ENDPOINT,
pathStyle: true,
partSize: 100 * 1024 * 1024,
httpOptions: {
agent: new https.Agent({
rejectUnauthorized: true,
ca: [fs.readFileSync('/certs/public.crt')],
}),
},
ca: [fs.readFileSync('/certs/public.crt')],
}
}