Repository navigation
Replies: 1 comment
|
I am looking for this. any solutions? |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
For users running their serverpod projects on DigitalOcean, they have a mostly S3-compatible service called Spaces. However, it does not support the
X-Amz-Security-Tokenheader -- documentation: https://docs.digitalocean.com/reference/api/spaces-api/Since AWS S3 endpoints and headers are hard-coded in
AwsS3Client, it currently cannot work with 3rd party services.I would like to propose a couple minor
AwsS3Clientchanges to support 3rd party S3 services by:... final credentialScope = SigV4.buildCredentialScope(datetime, _region, _service); final securityTokenHeaderName = _sessionToken != null ? ';x-amz-security-token' : ''; final securityTokenHeader = _sessionToken != null ? 'x-amz-security-token:$_sessionToken\n' : ''; final canonicalQuery = SigV4.buildCanonicalQueryString(queryParams); final canonicalRequest = '''$method ${'/$unencodedPath'.split('/').map(Uri.encodeComponent).join('/')} $canonicalQuery host:$_host x-amz-content-sha256:$payload x-amz-date:$datetime $securityTokenHeader host;x-amz-content-sha256;x-amz-date$securityTokenHeaderName $payload'''; final stringToSign = SigV4.buildStringToSign(datetime, credentialScope, SigV4.hashCanonicalRequest(canonicalRequest)); final signingKey = SigV4.calculateSigningKey(_secretKey, datetime, _region, _service); final signature = SigV4.calculateSignature(signingKey, stringToSign); final authorization = [ 'AWS4-HMAC-SHA256 Credential=$_accessKey/$credentialScope', 'SignedHeaders=host;x-amz-content-sha256;x-amz-date$securityTokenHeaderName', 'Signature=$signature', ].join(','); ...I have tested this on DigitalOcean with a
HEADrequest viaawait session.storage .verifyDirectFileUpload(...and verified that it fails (returns403/false) when thex-amz-security-tokenheader is included, but passes (returns200/true) when the header is removed from the canonical request and authorization strings.The direct upload from the server (not client), however, seemed to work without removing this header, but that might be a fluke on DigitalOcean as it's unsupported.
We have this property:
final String? _sessionToken;It does not seem to be currently used, as the call to the constructor in
s3_cloud_storage.dartis not currently using it.According to AWS S3 documentation, these session tokens are short-lived and pulled from IAM frequently, so they would seem to need to be passed with each request instead of when cloud storage is initialized on the server. Documentation: https://docs.aws.amazon.com/STS/latest/APIReference/CommonParameters.html
So there are two separate issues here, but since this IAM session token seems to be a future feature in development, I'm wondering if I could propose some changes to allow 3rd party S3 storage on S3-compatible services including the above suggestion?
All reactions