scireum / s3ninja

S3 ninja emulates the Amazon S3 API for developement and test purposes
MIT License
493 stars 91 forks source link

Is it possible to change configure a different Access Key and Secret Key? #235

Closed hradec closed 1 year ago

hradec commented 1 year ago

Is it possible to configure different keys than AKIAIOSFODNN7EXAMPLE and wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY?

I did a grep on the source, and it seems those 2 keys are hardcoded in some places:

$ grep AKIAIOSFODNN7EXAMPLE s3ninja/* -R
s3ninja/src/test/java/AWS4SignerWithPathSuffixAWSSpec.groovy:                "AKIAIOSFODNN7EXAMPLE",
s3ninja/src/test/java/AWS4SignerAWSSpec.groovy:                "AKIAIOSFODNN7EXAMPLE",
s3ninja/src/test/java/S3SignerAWSSpec.groovy:        AWSCredentials credentials = new BasicAWSCredentials("AKIAIOSFODNN7EXAMPLE",
s3ninja/src/test/java/S3ProxySpec.groovy:    private static final def secretKey = "AKIAIOSFODNN7EXAMPLE" + new Random().nextInt()
s3ninja/src/test/java/S3ProxySpec.groovy:        return createClient("AKIAIOSFODNN7EXAMPLE",
s3ninja/src/test/java/S3SignerWithPathSuffixAWSSpec.groovy:                "AKIAIOSFODNN7EXAMPLE",
s3ninja/src/main/resources/application.conf:  awsAccessKey = "AKIAIOSFODNN7EXAMPLE"

But they are also setup on src/main/resources/application.conf file. I'm wondering if changing then in that application.conf file would work? or do I need to change then on the other files too?

jakobvogel commented 1 year ago

Hello @hradec! The *.groovy files are unit tests. When running them, a special instance of S3 Ninja is booted that uses the default key. Without having checked it (as I am currently on vacation without my work computer 😇), you should be able to change the key for your local instance. You could try to create a file instance.conf, put it into the working directory, and within that, overwrite the respective two keys:

storage.awsAccessKey = "ABC"
storage.awsSecretKey = "XYZ"

Please let me know whether this works. 😊

jakobvogel commented 1 year ago

Lacking further input, we assume this to be solved.

asessohradec commented 1 year ago

I didn't have time to test yet. I'll reply here as soon as I do! Thanks for the help, really appreciate!