1
0
mirror of https://github.com/pocketbase/pocketbase.git synced 2025-02-10 12:36:41 +02:00

[#6313] enforced when_required for the new aws sdk request and response cheksum validations

This commit is contained in:
Gani Georgiev 2025-01-19 22:09:47 +02:00
parent 2124b77a2a
commit 7da875be14
2 changed files with 27 additions and 0 deletions

View File

@ -17,6 +17,9 @@
- Soft-deprecated `Record.GetUploadedFiles` in favour of `Record.GetUnsavedFiles` to minimize the ambiguities what the method do ([#6269](https://github.com/pocketbase/pocketbase/discussions/6269)).
(@todo update docs to reflect the `:unsaved` getter change)
- Enforced `when_required` for the new AWS SDK request and response checksum validations to allow other non-AWS vendors to catch up with new AWS SDK changes (see [#6313](https://github.com/pocketbase/pocketbase/discussions/6313) and [aws/aws-sdk-go-v2#2960](https://github.com/aws/aws-sdk-go-v2/discussions/2960)).
_You can set the environment variables `AWS_REQUEST_CHECKSUM_CALCULATION` and `AWS_RESPONSE_CHECKSUM_VALIDATION` to `when_supported` if your S3 vendor supports the new [new default integrity protections](https://docs.aws.amazon.com/sdkref/latest/guide/feature-dataintegrity.html)._
## v0.24.4

View File

@ -36,6 +36,27 @@ type System struct {
bucket *blob.Bucket
}
// -------------------------------------------------------------------
var requestChecksumCalculation = aws.RequestChecksumCalculationWhenRequired
var responseChecksumValidation = aws.ResponseChecksumValidationWhenRequired
// @todo consider removing after the other non-AWS vendors catched up with the new changes
// (https://github.com/aws/aws-sdk-go-v2/discussions/2960)
func init() {
reqEnv := os.Getenv("AWS_REQUEST_CHECKSUM_CALCULATION")
if reqEnv != "" && strings.EqualFold(reqEnv, "when_supported") {
requestChecksumCalculation = aws.RequestChecksumCalculationWhenSupported
}
resEnv := os.Getenv("AWS_RESPONSE_CHECKSUM_VALIDATION")
if resEnv != "" && strings.EqualFold(resEnv, "when_supported") {
responseChecksumValidation = aws.ResponseChecksumValidationWhenSupported
}
}
// -------------------------------------------------------------------
// NewS3 initializes an S3 filesystem instance.
//
// NB! Make sure to call `Close()` after you are done working with it.
@ -60,6 +81,9 @@ func NewS3(
return nil, err
}
cfg.RequestChecksumCalculation = requestChecksumCalculation
cfg.ResponseChecksumValidation = responseChecksumValidation
client := s3.NewFromConfig(cfg, func(o *s3.Options) {
// ensure that the endpoint has url scheme for
// backward compatibility with v1 of the aws sdk