-
Notifications
You must be signed in to change notification settings - Fork 475
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added contracts for cognito pre token generation v2_0 (#1656)
- Loading branch information
1 parent
d77b8b3
commit d0d73dc
Showing
10 changed files
with
353 additions
and
3 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
Libraries/src/Amazon.Lambda.CognitoEvents/AccessTokenGeneration.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 |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Collections.Generic; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Amazon.Lambda.CognitoEvents | ||
{ | ||
/// <summary> | ||
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html | ||
/// </summary> | ||
[DataContract] | ||
public class AccessTokenGeneration | ||
{ | ||
/// <summary> | ||
/// A map of one or more key-value pairs of claims to add or override. For group related claims, use | ||
/// groupOverrideDetails instead. | ||
/// </summary> | ||
[DataMember(Name = "claimsToAddOrOverride")] | ||
#if NETCOREAPP3_1_OR_GREATER | ||
[System.Text.Json.Serialization.JsonPropertyName("claimsToAddOrOverride")] | ||
# endif | ||
public Dictionary<string, string> ClaimsToAddOrOverride { get; set; } = new Dictionary<string, string>(); | ||
|
||
/// <summary> | ||
/// A list that contains claims to be suppressed from the identity token. | ||
/// </summary> | ||
[DataMember(Name = "claimsToSuppress")] | ||
#if NETCOREAPP3_1_OR_GREATER | ||
[System.Text.Json.Serialization.JsonPropertyName("claimsToSuppress")] | ||
# endif | ||
public List<string> ClaimsToSuppress { get; set; } = new List<string>(); | ||
|
||
/// <summary> | ||
/// A list of OAuth 2.0 scopes that you want to add to the scope claim in your user's access token. You can't | ||
/// add scope values that contain one or more blank-space characters. | ||
/// </summary> | ||
[DataMember(Name = "scopesToAdd")] | ||
#if NETCOREAPP3_1_OR_GREATER | ||
[System.Text.Json.Serialization.JsonPropertyName("scopesToAdd")] | ||
# endif | ||
public List<string> ScopesToAdd { get; set; } = new List<string>(); | ||
|
||
/// <summary> | ||
/// A list of OAuth 2.0 scopes that you want to remove from the scope claim in your user's access token. | ||
/// </summary> | ||
[DataMember(Name = "scopesToSuppress")] | ||
#if NETCOREAPP3_1_OR_GREATER | ||
[System.Text.Json.Serialization.JsonPropertyName("scopesToSuppress")] | ||
# endif | ||
public List<string> ScopesToSuppress { get; set; } = new List<string>(); | ||
} | ||
} |
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
38 changes: 38 additions & 0 deletions
38
Libraries/src/Amazon.Lambda.CognitoEvents/ClaimsAndScopeOverrideDetails.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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace Amazon.Lambda.CognitoEvents | ||
{ | ||
/// <summary> | ||
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html | ||
/// </summary> | ||
[DataContract] | ||
public class ClaimsAndScopeOverrideDetails | ||
{ | ||
/// <summary> | ||
/// The claims that you want to override, add, or suppress in your user’s ID token. | ||
/// </summary> | ||
[DataMember(Name = "idTokenGeneration")] | ||
#if NETCOREAPP3_1_OR_GREATER | ||
[System.Text.Json.Serialization.JsonPropertyName("idTokenGeneration")] | ||
# endif | ||
public IdTokenGeneration IdTokenGeneration { get; set; } = new IdTokenGeneration(); | ||
|
||
/// <summary> | ||
/// The claims and scopes that you want to override, add, or suppress in your user’s access token. | ||
/// </summary> | ||
[DataMember(Name = "accessTokenGeneration")] | ||
#if NETCOREAPP3_1_OR_GREATER | ||
[System.Text.Json.Serialization.JsonPropertyName("accessTokenGeneration")] | ||
# endif | ||
public AccessTokenGeneration AccessTokenGeneration { get; set; } = new AccessTokenGeneration(); | ||
|
||
/// <summary> | ||
/// The output object containing the current group configuration. It includes groupsToOverride, iamRolesToOverride, and preferredRole. | ||
/// </summary> | ||
[DataMember(Name = "groupOverrideDetails")] | ||
#if NETCOREAPP3_1_OR_GREATER | ||
[System.Text.Json.Serialization.JsonPropertyName("groupOverrideDetails")] | ||
# endif | ||
public GroupConfiguration GroupOverrideDetails { get; set; } = new GroupConfiguration(); | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
Libraries/src/Amazon.Lambda.CognitoEvents/CognitoPreTokenGenerationV2Event.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace Amazon.Lambda.CognitoEvents | ||
{ | ||
/// <summary> | ||
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html | ||
/// </summary> | ||
public class CognitoPreTokenGenerationV2Event : CognitoTriggerEvent<CognitoPreTokenGenerationV2Request, CognitoPreTokenGenerationV2Response> | ||
{ | ||
} | ||
} |
38 changes: 38 additions & 0 deletions
38
Libraries/src/Amazon.Lambda.CognitoEvents/CognitoPreTokenGenerationV2Request.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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
using System.Collections.Generic; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Amazon.Lambda.CognitoEvents | ||
{ | ||
/// <summary> | ||
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html | ||
/// </summary> | ||
public class CognitoPreTokenGenerationV2Request : CognitoTriggerRequest | ||
{ | ||
/// <summary> | ||
/// The input object containing the current group configuration. It includes groupsToOverride, iamRolesToOverride, and preferredRole. | ||
/// </summary> | ||
[DataMember(Name = "groupConfiguration")] | ||
#if NETCOREAPP3_1_OR_GREATER | ||
[System.Text.Json.Serialization.JsonPropertyName("groupConfiguration")] | ||
# endif | ||
public GroupConfiguration GroupConfiguration { get; set; } = new GroupConfiguration(); | ||
|
||
/// <summary> | ||
/// One or more key-value pairs that you can provide as custom input to the Lambda function that you specify for the pre sign-up trigger. You can pass this data to your Lambda function by using the ClientMetadata parameter in the following API actions: AdminVerifyUser, AdminRespondToAuthChallenge, ForgotPassword, and SignUp. | ||
/// </summary> | ||
[DataMember(Name = "clientMetadata")] | ||
#if NETCOREAPP3_1_OR_GREATER | ||
[System.Text.Json.Serialization.JsonPropertyName("clientMetadata")] | ||
# endif | ||
public Dictionary<string, string> ClientMetadata { get; set; } = new Dictionary<string, string>(); | ||
|
||
/// <summary> | ||
/// A list that contains the OAuth 2.0 user scopes. | ||
/// </summary> | ||
[DataMember(Name = "scopes")] | ||
#if NETCOREAPP3_1_OR_GREATER | ||
[System.Text.Json.Serialization.JsonPropertyName("scopes")] | ||
# endif | ||
public List<string> Scopes { get; set; } = new List<string>(); | ||
} | ||
} |
19 changes: 19 additions & 0 deletions
19
Libraries/src/Amazon.Lambda.CognitoEvents/CognitoPreTokenGenerationV2Response.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 |
---|---|---|
@@ -0,0 +1,19 @@ | ||
using System.Runtime.Serialization; | ||
|
||
namespace Amazon.Lambda.CognitoEvents | ||
{ | ||
/// <summary> | ||
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html | ||
/// </summary> | ||
public class CognitoPreTokenGenerationV2Response : CognitoTriggerResponse | ||
{ | ||
/// <summary> | ||
/// A container for all elements in a V2_0 trigger event. | ||
/// </summary> | ||
[DataMember(Name = "claimsAndScopeOverrideDetails")] | ||
#if NETCOREAPP3_1_OR_GREATER | ||
[System.Text.Json.Serialization.JsonPropertyName("claimsAndScopeOverrideDetails")] | ||
# endif | ||
public ClaimsAndScopeOverrideDetails ClaimsAndScopeOverrideDetails { get; set; } = new ClaimsAndScopeOverrideDetails(); | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
Libraries/src/Amazon.Lambda.CognitoEvents/IdTokenGeneration.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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using System.Collections.Generic; | ||
using System.Runtime.Serialization; | ||
|
||
namespace Amazon.Lambda.CognitoEvents | ||
{ | ||
/// <summary> | ||
/// https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html | ||
/// </summary> | ||
[DataContract] | ||
public class IdTokenGeneration | ||
{ | ||
/// <summary> | ||
/// A map of one or more key-value pairs of claims to add or override. For group related claims, use groupOverrideDetails instead. | ||
/// </summary> | ||
[DataMember(Name = "claimsToAddOrOverride")] | ||
#if NETCOREAPP3_1_OR_GREATER | ||
[System.Text.Json.Serialization.JsonPropertyName("claimsToAddOrOverride")] | ||
# endif | ||
public Dictionary<string, string> ClaimsToAddOrOverride { get; set; } = new Dictionary<string, string>(); | ||
|
||
/// <summary> | ||
/// A list that contains claims to be suppressed from the identity token. | ||
/// </summary> | ||
[DataMember(Name = "claimsToSuppress")] | ||
#if NETCOREAPP3_1_OR_GREATER | ||
[System.Text.Json.Serialization.JsonPropertyName("claimsToSuppress")] | ||
# endif | ||
public List<string> ClaimsToSuppress { get; set; } = new List<string>(); | ||
} | ||
} |
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
Oops, something went wrong.