Tchorzyksen
Tchorzyksen

Reputation: 47

Minio does not authorize putObject request

I'm trying to integrate with Minio running locally. My plan is to upload an image to a bucket. You can find implementation here https://github.com/Tchorzyksen37/my-service-backend/tree/Upload-logo-to-s3

Running application, I'm getting error response from minio server The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256. Which makes no sense to me because as I understand AmazonS3 is already using this authentication algorithm by default, thus no extra configuration should be necessary.

My AmazonS3 config

  @Bean
  AmazonS3 amazonS3() {
    var credentialsProviderChain = new AWSCredentialsProviderChain(new EnvironmentVariableCredentialsProvider());
    return AmazonS3ClientBuilder.standard()
            .withCredentials(credentialsProviderChain)
            .withEndpointConfiguration(new EndpointConfiguration(s3Url, "eu-central-1"))
            .build();
  }

logs:

14:39:28.728 [http-nio-8080-exec-1] DEBUG com.amazonaws.auth.AWS4Signer - AWS4 Canonical Request: '"PUT
/some.jpg

amz-sdk-invocation-id:de23a125-f70b-45a6-669e-707ae8b64980
amz-sdk-request:attempt=1;max=4
amz-sdk-retry:0/0/500
content-length:187691
content-type:application/octet-stream
host:logo.localhost:9000
user-agent:aws-sdk-java/1.12.523 Linux/6.2.0-26-generic OpenJDK_64-Bit_Server_VM/19.0.2+7-FR java/19.0.2 vendor/Amazon.com_Inc. cfg/retry-mode/legacy
x-amz-content-sha256:STREAMING-AWS4-HMAC-SHA256-PAYLOAD
x-amz-date:20230806T123928Z
x-amz-decoded-content-length:187426

amz-sdk-invocation-id;amz-sdk-request;amz-sdk-retry;content-length;content-type;host;user-agent;x-amz-content-sha256;x-amz-date;x-amz-decoded-content-length
STREAMING-AWS4-HMAC-SHA256-PAYLOAD"
14:39:28.728 [http-nio-8080-exec-1] DEBUG com.amazonaws.auth.AWS4Signer - AWS4 String to Sign: '"AWS4-HMAC-SHA256
20230806T123928Z
20230806/eu-central-1/s3/aws4_request
cc6874ec35a2fd4fd0a8cb29ae3a5278d2c5199d97ce6c10f223ac5ee421f521"
14:39:28.728 [http-nio-8080-exec-1] DEBUG com.amazonaws.auth.AWS4Signer - Generating a new signing key as the signing key not available in the cache for the date 1691280000000

To run my code locally you have to run 2 containers from Dockerfile under docker directory. And provide following run configuration

    <option name="ACTIVE_PROFILES" value="local" />
    <envs>
      <env name="AWS_ACCESS_KEY" value="" />
      <env name="AWS_SECRET_KEY" value="" />
      <env name="SMTP_PASSWORD" value="test" />
    </envs>

Where AWS_ACCESS_KEY and AWS_SECRET_KEY comes from minio enter image description here

Thanks for your time and help :D

Upvotes: 0

Views: 1085

Answers (1)

Tchorzyksen
Tchorzyksen

Reputation: 47

You can find answer here https://github.com/minio/minio/issues/1008 Simply it's enough to disable chunked encoding.

Upvotes: 0

Related Questions