@contember/engine-s3-plugin 2.1.0-beta.2 → 2.1.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/development/src/S3Service.cjs +3 -2
- package/dist/development/src/S3Service.cjs.map +1 -1
- package/dist/development/src/S3Service.js +3 -2
- package/dist/development/src/S3Service.js.map +1 -1
- package/dist/production/src/S3Service.cjs +3 -2
- package/dist/production/src/S3Service.cjs.map +1 -1
- package/dist/production/src/S3Service.js +3 -2
- package/dist/production/src/S3Service.js.map +1 -1
- package/dist/tests/tsconfig.tsbuildinfo +1 -1
- package/dist/types/S3Service.d.ts.map +1 -1
- package/dist/types/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/S3Service.ts +4 -2
- package/tests/cases/signRequest.test.ts +7 -0
package/package.json
CHANGED
package/src/S3Service.ts
CHANGED
|
@@ -102,12 +102,14 @@ export class S3Service {
|
|
|
102
102
|
if (objectKey.startsWith(publicPrefix)) {
|
|
103
103
|
objectKey = objectKey.substring(publicPrefix.length)
|
|
104
104
|
}
|
|
105
|
-
|
|
105
|
+
// the separator is a part of the prefix: without it, a project prefixed "blog" reaches into "blog-staging" in a shared bucket
|
|
106
|
+
const prefix = this.config.prefix ? this.config.prefix + '/' : ''
|
|
107
|
+
if (prefix && !objectKey.startsWith(prefix)) {
|
|
106
108
|
throw new ForbiddenError(
|
|
107
109
|
`Given object key "${objectKey}" does not start with a project prefix "${this.config.prefix}"`,
|
|
108
110
|
)
|
|
109
111
|
}
|
|
110
|
-
const localObjectKey =
|
|
112
|
+
const localObjectKey = objectKey.substring(prefix.length)
|
|
111
113
|
this.authorizator.verifyReadAccess({ key: localObjectKey })
|
|
112
114
|
|
|
113
115
|
const url = this.signer.sign({
|
|
@@ -37,6 +37,13 @@ test('sign s3 request - prefix', () => {
|
|
|
37
37
|
)
|
|
38
38
|
})
|
|
39
39
|
|
|
40
|
+
test('sign s3 request - a sibling prefix is not a prefix', () => {
|
|
41
|
+
const service = createS3Service('test', 'lorem')
|
|
42
|
+
expect(() => service.getSignedReadUrl({ objectKey: 'loremipsum/foo.jpg', expiration: null })).toThrow(
|
|
43
|
+
'Given object key "loremipsum/foo.jpg" does not start with a project prefix "lorem"',
|
|
44
|
+
)
|
|
45
|
+
})
|
|
46
|
+
|
|
40
47
|
test('sign upload', () => {
|
|
41
48
|
const service = createS3Service('test')
|
|
42
49
|
const signed = service.getSignedUploadUrl({
|