Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend V4Authenticator constructor to take region #265

Merged
merged 1 commit into from
Dec 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Minio/MinioClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ internal void initClient()
restClient = new RestSharp.RestClient(this.uri);
restClient.UserAgent = this.FullUserAgent;

authenticator = new V4Authenticator(this.Secure,this.AccessKey, this.SecretKey);
authenticator = new V4Authenticator(this.Secure,this.AccessKey, this.SecretKey, this.Region);
restClient.Authenticator = authenticator;
}

Expand Down
22 changes: 21 additions & 1 deletion Minio/V4Authenticator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,16 +75,36 @@ internal class V4Authenticator : IAuthenticator
/// <param name="secure"></param>
/// <param name="accessKey">Access key id</param>
/// <param name="secretKey">Secret access key</param>
public V4Authenticator(bool secure,string accessKey, string secretKey)
public V4Authenticator(bool secure, string accessKey, string secretKey)
{
this.isSecure = secure;
this.accessKey = accessKey;
this.secretKey = secretKey;
this.isAnonymous = String.IsNullOrEmpty(accessKey) && String.IsNullOrEmpty(secretKey);
}

/// <summary>
/// Authenticator constructor with region specified.
/// </summary>
/// <param name="secure"></param>
/// <param name="accessKey">Access key id</param>
/// <param name="secretKey">Secret access key</param>
/// <param name="region">Region</param>
public V4Authenticator(bool secure, string accessKey, string secretKey, string region)
{
this.isSecure = secure;
this.accessKey = accessKey;
this.secretKey = secretKey;
this.isAnonymous = String.IsNullOrEmpty(accessKey) && String.IsNullOrEmpty(secretKey);
this.Region = region;
}

private String getRegion(string url)
{
if (!string.IsNullOrEmpty(this.Region))
{
return this.Region;
}
string region = Regions.GetRegionFromEndpoint(url);
return (region == "") ? "us-east-1" : region;
}
Expand Down