-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Exponential backoff + Cosmos DB serializer * Update libs and use new lang features
- Loading branch information
1 parent
48bfe95
commit e9a059c
Showing
426 changed files
with
8,417 additions
and
8,884 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 6 additions & 8 deletions
14
AWS/Mcma.Api.Aws.ApiGateway/ApiGatewayServiceCollectionExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
using System; | ||
using Mcma.Api; | ||
using Mcma.Api.Http; | ||
using Microsoft.Extensions.DependencyInjection; | ||
|
||
namespace Mcma.Api.Aws.ApiGateway | ||
namespace Mcma.Api.Aws.ApiGateway; | ||
|
||
public static class ApiGatewayServiceCollectionExtensions | ||
{ | ||
public static class ApiGatewayServiceCollectionExtensions | ||
{ | ||
public static IServiceCollection AddMcmaApiGatewayApi(this IServiceCollection services, Action<McmaApiBuilder> build) | ||
=> services.AddMcmaApi(build) | ||
.AddSingleton<IApiGatewayApiController, ApiGatewayApiController>(); | ||
} | ||
public static IServiceCollection AddMcmaApiGatewayApi(this IServiceCollection services, Action<McmaApiBuilder> build) | ||
=> services.AddMcmaApi(build) | ||
.AddSingleton<IApiGatewayApiController, ApiGatewayApiController>(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,47 @@ | ||
using Amazon.Runtime.CredentialManagement; | ||
|
||
namespace Mcma.Client.Aws | ||
namespace Mcma.Client.Aws; | ||
|
||
public class Aws4AuthContext | ||
{ | ||
public class Aws4AuthContext | ||
public Aws4AuthContext() | ||
{ | ||
} | ||
|
||
public Aws4AuthContext(string accessKey, string secretKey, string region, string sessionToken = null) | ||
{ | ||
AccessKey = accessKey; | ||
SecretKey = secretKey; | ||
Region = region; | ||
SessionToken = sessionToken; | ||
} | ||
|
||
public string AccessKey { get; set; } | ||
|
||
public string SecretKey { get; set; } | ||
|
||
public string Region { get; set; } | ||
|
||
public string SessionToken { get; set; } | ||
|
||
public static Aws4AuthContext Global { get; } = | ||
new(AwsEnvironmentVariables.AccessKey, | ||
AwsEnvironmentVariables.SecretKey, | ||
AwsEnvironmentVariables.Region, | ||
AwsEnvironmentVariables.SessionToken); | ||
|
||
public static Aws4AuthContext ForProfile(string profileName) | ||
{ | ||
public Aws4AuthContext() | ||
{ | ||
} | ||
|
||
public Aws4AuthContext(string accessKey, string secretKey, string region, string sessionToken = null) | ||
{ | ||
AccessKey = accessKey; | ||
SecretKey = secretKey; | ||
Region = region; | ||
SessionToken = sessionToken; | ||
} | ||
|
||
public string AccessKey { get; set; } | ||
|
||
public string SecretKey { get; set; } | ||
|
||
public string Region { get; set; } | ||
|
||
public string SessionToken { get; set; } | ||
|
||
public static Aws4AuthContext Global { get; } = | ||
new(AwsEnvironmentVariables.AccessKey, | ||
AwsEnvironmentVariables.SecretKey, | ||
AwsEnvironmentVariables.Region, | ||
AwsEnvironmentVariables.SessionToken); | ||
|
||
public static Aws4AuthContext ForProfile(string profileName) | ||
{ | ||
var sharedCredentialsFile = new SharedCredentialsFile(); | ||
if (!sharedCredentialsFile.TryGetProfile(profileName, out var profile)) | ||
throw new McmaException("AWS profile with name '{profileName}' not found in shared credentials file."); | ||
|
||
var awsCredentials = profile.GetAWSCredentials(sharedCredentialsFile); | ||
var credentials = awsCredentials.GetCredentials(); | ||
|
||
return new Aws4AuthContext(credentials.AccessKey, | ||
credentials.SecretKey, | ||
profile.Region.SystemName, | ||
credentials.UseToken ? credentials.Token : null); | ||
} | ||
var sharedCredentialsFile = new SharedCredentialsFile(); | ||
if (!sharedCredentialsFile.TryGetProfile(profileName, out var profile)) | ||
throw new McmaException("AWS profile with name '{profileName}' not found in shared credentials file."); | ||
|
||
var awsCredentials = profile.GetAWSCredentials(sharedCredentialsFile); | ||
var credentials = awsCredentials.GetCredentials(); | ||
|
||
return new Aws4AuthContext(credentials.AccessKey, | ||
credentials.SecretKey, | ||
profile.Region.SystemName, | ||
credentials.UseToken ? credentials.Token : null); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,24 @@ | ||
using System.Net.Http; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Mcma.Client; | ||
using Mcma.Client.Auth; | ||
|
||
namespace Mcma.Client.Aws | ||
{ | ||
public class Aws4Authenticator : IAuthenticator | ||
namespace Mcma.Client.Aws; | ||
|
||
public class Aws4Authenticator : IAuthenticator | ||
{ | ||
public Aws4Authenticator(Aws4AuthContext authContext) | ||
{ | ||
public Aws4Authenticator(Aws4AuthContext authContext) | ||
{ | ||
Signer = | ||
new Aws4Signer( | ||
authContext.AccessKey, | ||
authContext.SecretKey, | ||
authContext.Region, | ||
authContext.SessionToken); | ||
} | ||
Signer = | ||
new Aws4Signer( | ||
authContext.AccessKey, | ||
authContext.SecretKey, | ||
authContext.Region, | ||
authContext.SessionToken); | ||
} | ||
|
||
private Aws4Signer Signer { get; } | ||
private Aws4Signer Signer { get; } | ||
|
||
public Task AuthenticateAsync(HttpRequestMessage request, CancellationToken cancellationToken = default) | ||
=> Signer.SignAsync(request, cancellationToken: cancellationToken); | ||
} | ||
public Task AuthenticateAsync(HttpRequestMessage request, CancellationToken cancellationToken = default) | ||
=> Signer.SignAsync(request, cancellationToken: cancellationToken); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,20 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Mcma.Client; | ||
using System.Threading.Tasks; | ||
using Mcma.Client.Auth; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Mcma.Client.Aws | ||
namespace Mcma.Client.Aws; | ||
|
||
internal class Aws4AuthenticatorFactory : AuthenticatorFactory<Aws4AuthContext> | ||
{ | ||
internal class Aws4AuthenticatorFactory : AuthenticatorFactory<Aws4AuthContext> | ||
public Aws4AuthenticatorFactory(IOptions<Aws4AuthenticatorFactoryOptions> options) | ||
{ | ||
public Aws4AuthenticatorFactory(IOptions<Aws4AuthenticatorFactoryOptions> options) | ||
{ | ||
Options = options.Value ?? new Aws4AuthenticatorFactoryOptions(); | ||
} | ||
Options = options.Value ?? new Aws4AuthenticatorFactoryOptions(); | ||
} | ||
|
||
private Aws4AuthenticatorFactoryOptions Options { get; } | ||
private Aws4AuthenticatorFactoryOptions Options { get; } | ||
|
||
protected override Aws4AuthContext DefaultAuthContext => Options.DefaultAuthContext; | ||
protected override Aws4AuthContext DefaultAuthContext => Options.DefaultAuthContext; | ||
|
||
protected override Task<IAuthenticator> GetAsync(Aws4AuthContext authContext) | ||
=> Task.FromResult<IAuthenticator>(new Aws4Authenticator(authContext)); | ||
} | ||
protected override Task<IAuthenticator> GetAsync(Aws4AuthContext authContext) | ||
=> Task.FromResult<IAuthenticator>(new Aws4Authenticator(authContext)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
namespace Mcma.Client.Aws | ||
namespace Mcma.Client.Aws; | ||
|
||
public class Aws4AuthenticatorFactoryOptions | ||
{ | ||
public class Aws4AuthenticatorFactoryOptions | ||
{ | ||
public Aws4AuthContext DefaultAuthContext { get; set; } = Aws4AuthContext.Global; | ||
} | ||
public Aws4AuthContext DefaultAuthContext { get; set; } = Aws4AuthContext.Global; | ||
} |
Oops, something went wrong.