Skip to content
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
18 changes: 11 additions & 7 deletions extensions/AWS/S3/AWSS3Config.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft. All rights reserved.
// Copyright (c) Microsoft. All rights reserved.

using System.Text.Json.Serialization;

Expand All @@ -13,6 +13,7 @@ public enum AuthTypes
{
Unknown = -1,
AccessKey,
CredentialChain,
}

public AuthTypes Auth { get; set; } = AuthTypes.Unknown;
Expand Down Expand Up @@ -45,14 +46,17 @@ public void Validate()
throw new ConfigurationException($"Authentication type '{this.Auth}' undefined or not supported");
}

if (string.IsNullOrWhiteSpace(this.AccessKey))
if (this.Auth == AuthTypes.AccessKey)
{
throw new ConfigurationException("S3 Access Key is undefined");
}
if (string.IsNullOrWhiteSpace(this.AccessKey))
{
throw new ConfigurationException("S3 Access Key is undefined");
}

if (string.IsNullOrWhiteSpace(this.SecretAccessKey))
{
throw new ConfigurationException("S3 Secret Key Access undefined");
if (string.IsNullOrWhiteSpace(this.SecretAccessKey))
{
throw new ConfigurationException("S3 Secret Key Access undefined");
}
}

if (string.IsNullOrWhiteSpace(this.BucketName))
Expand Down
11 changes: 10 additions & 1 deletion extensions/AWS/S3/AWSS3Storage.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) Microsoft. All rights reserved.
// Copyright (c) Microsoft. All rights reserved.

using System;
using System.Collections.Generic;
Expand Down Expand Up @@ -43,6 +43,15 @@ public AWSS3Storage(
);
break;
}
case AWSS3Config.AuthTypes.CredentialChain:
{
this._client = new AmazonS3Client(new AmazonS3Config
{
ServiceURL = config.Endpoint,
LogResponse = true
});
break;
}

default:
this._log.LogCritical("Authentication type '{0}' undefined or not supported", config.Auth);
Expand Down
1 change: 1 addition & 0 deletions service/Service/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@
"HttpClientName": ""
},
"AWSS3": {
// "AccessKey" or "CredentialChain". For other options see <AWSS3Config>.
"Auth": "AccessKey",
// AccessKey ID, required when using AccessKey auth
// Note: you can use an env var 'KernelMemory__Services__AWSS3__AccessKey' to set this
Expand Down
Loading