-
Notifications
You must be signed in to change notification settings - Fork 490
Add AWS AppSyncEvent #1939
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
Add AWS AppSyncEvent #1939
Changes from 15 commits
64d401c
4335914
f287562
1bb2045
033f1e8
204e17a
87f899a
8ebea50
24aafb0
634f4a4
2fdb768
0ad9cd6
f2af59d
247a2be
4356b85
9b8f7ae
f94d588
5180735
0708f45
d7cd825
1c34513
1530839
06fe270
308156c
e37ad36
3990078
25190da
d2469ca
11723b0
089f411
e74bda3
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"Projects": [ | ||
{ | ||
"Name": "Amazon.Lambda.AppSyncEvents", | ||
"Type": "Major", | ||
"ChangelogMessages": [ | ||
"Added AppSyncResolverEvent to support direct lambda resolver" | ||
] | ||
} | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<Import Project="..\..\..\buildtools\common.props" /> | ||
|
||
<PropertyGroup> | ||
<Description>Amazon Lambda .NET Core support - AWS AppSync package.</Description> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: we don't need to mention "Core" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed |
||
<TargetFrameworks>netstandard2.0;netcoreapp3.1;net8.0</TargetFrameworks> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since this is a new package, we should only target There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. NET 8 test was written in the 'EventsTests.NET6' project, so I included both net6.0 and net8.0 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We shouldn't add a "net6.0" target. For the tests, you could create a 'EventsTests.NET8' project and add the tests there. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added new project - EventsTests.NET8 |
||
<AssemblyTitle>Amazon.Lambda.AppSyncEvents</AssemblyTitle> | ||
<Version>0.0.1</Version> | ||
<AssemblyName>Amazon.Lambda.AppSyncEvents</AssemblyName> | ||
<PackageId>Amazon.Lambda.AppSyncEvents</PackageId> | ||
<PackageTags>AWS;Amazon;Lambda</PackageTags> | ||
</PropertyGroup> | ||
|
||
<!-- .NET Standard 2.0 specific settings --> | ||
<PropertyGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> | ||
<DefineConstants>NETSTANDARD_2_0</DefineConstants> | ||
<WarningsAsErrors>IL2026,IL2067,IL2075</WarningsAsErrors> | ||
<IsTrimmable>true</IsTrimmable> | ||
<EnableTrimAnalyzer>true</EnableTrimAnalyzer> | ||
</PropertyGroup> | ||
|
||
<!-- Newtonsoft.Json only for .NET Standard 2.0 --> | ||
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'"> | ||
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" /> | ||
</ItemGroup> | ||
|
||
<!-- System.Text.Json for .NET Core 3.1 and .NET 8.0 --> | ||
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.1' OR '$(TargetFramework)' == 'net8.0'"> | ||
<PackageReference Include="System.Text.Json" Version="8.0.5" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Amazon.Lambda.AppSyncEvents | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use top level statement |
||
{ | ||
// Represents an AppSync authorization event | ||
public class AppSyncAuthorizerEvent | ||
{ | ||
// The authorization token from the request | ||
public string AuthorizationToken { get; set; } | ||
|
||
// Headers from the request | ||
public Dictionary<string, string> RequestHeaders { get; set; } | ||
|
||
// Context information about the request | ||
public RequestContext RequestContext { get; set; } | ||
} | ||
|
||
// Request context for AppSync authorization | ||
|
||
public class RequestContext | ||
{ | ||
// The ID of the AppSync API | ||
public string ApiId { get; set; } | ||
|
||
// The AWS account ID | ||
public string AccountId { get; set; } | ||
|
||
// Unique identifier for the request | ||
public string RequestId { get; set; } | ||
|
||
// The GraphQL query string | ||
public string QueryString { get; set; } | ||
|
||
// Name of the GraphQL operation | ||
public string OperationName { get; set; } | ||
|
||
/// Variables passed to the GraphQL operation. | ||
public Dictionary<string, object> Variables { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
@@ -0,0 +1,44 @@ | ||||
using System.Collections.Generic; | ||||
#if NETSTANDARD_2_0 | ||||
using Newtonsoft.Json; | ||||
#else | ||||
using System.Text.Json.Serialization; | ||||
#endif | ||||
|
||||
namespace Amazon.Lambda.AppSyncEvents | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use top level statement There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||||
{ | ||||
public class AppSyncAuthorizerResult | ||||
{ | ||||
// Indicates if the request is authorized | ||||
#if NETSTANDARD_2_0 | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ashishdhingra Added JsonProperty attribute, since AWS AppSync is case sensitive. I hope this is correct way to support both type of serializer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Almost there. Please follow approach at aws-lambda-dotnet/Libraries/src/Amazon.Lambda.KinesisEvents/KinesisTimeWindowResponse.cs Line 33 in 6eca899
Amazon.Lambda.KinesisEvents also targets netstandard2.0;netcoreapp3.1;net8.0 .
Also, readme doesn't demonstrate Once this is done, I will pull PR branch locally and validate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ashishdhingra - Pushed the following changes:
Added new tests, updated readme and incorporated review comments](9b8f7ae) |
||||
[JsonProperty("isAuthorized")] | ||||
#else | ||||
[JsonPropertyName("isAuthorized")] | ||||
#endif | ||||
public bool IsAuthorized { get; set; } | ||||
|
||||
// Custom context to pass to resolvers, only supports key-value pairs. | ||||
#if NETSTANDARD_2_0 | ||||
[JsonProperty("resolverContext")] | ||||
#else | ||||
[JsonPropertyName("resolverContext")] | ||||
#endif | ||||
public Dictionary<string, string> ResolverContext { get; set; } | ||||
|
||||
// List of fields that are denied access | ||||
#if NETSTANDARD_2_0 | ||||
[JsonProperty("deniedFields")] | ||||
#else | ||||
[JsonPropertyName("deniedFields")] | ||||
#endif | ||||
public IEnumerable<string> DeniedFields { get; set; } | ||||
|
||||
// The number of seconds that the response should be cached for | ||||
#if NETSTANDARD_2_0 | ||||
[JsonProperty("ttlOverride")] | ||||
#else | ||||
[JsonPropertyName("ttlOverride")] | ||||
#endif | ||||
public int? TtlOverride { get; set; } | ||||
} | ||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Amazon.Lambda.AppSyncEvents | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use top level statement There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
{ | ||
/// <summary> | ||
/// Represents Amazon Cognito User Pools authorization identity for AppSync | ||
/// </summary> | ||
public class AppSyncCognitoIdentity | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why we didn't implement There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @PankajRawat333 Please advise on this. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Added |
||
{ | ||
/// <summary> | ||
/// The source IP address of the caller received by AWS AppSync | ||
/// </summary> | ||
public List<string> SourceIp { get; set; } | ||
|
||
/// <summary> | ||
/// The username of the authenticated user | ||
/// </summary> | ||
public string Username { get; set; } | ||
|
||
/// <summary> | ||
/// The UUID of the authenticated user | ||
/// </summary> | ||
public string Sub { get; set; } | ||
|
||
/// <summary> | ||
/// The claims that the user has | ||
/// </summary> | ||
public Dictionary<string, object> Claims { get; set; } | ||
|
||
/// <summary> | ||
/// The default authorization strategy for this caller (ALLOW or DENY) | ||
/// </summary> | ||
public string DefaultAuthStrategy { get; set; } | ||
|
||
/// <summary> | ||
/// List of OIDC groups | ||
/// </summary> | ||
public List<string> Groups { get; set; } | ||
|
||
/// <summary> | ||
/// The token issuer | ||
/// </summary> | ||
public string Issuer { get; set; } | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Amazon.Lambda.AppSyncEvents | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use top level statement There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
{ | ||
/// <summary> | ||
/// Represents AWS IAM authorization identity for AppSync | ||
/// </summary> | ||
public class AppSyncIamIdentity | ||
{ | ||
/// <summary> | ||
/// The source IP address of the caller received by AWS AppSync | ||
/// </summary> | ||
public List<string> SourceIp { get; set; } | ||
|
||
/// <summary> | ||
/// The username of the authenticated user (IAM user principal) | ||
/// </summary> | ||
public string Username { get; set; } | ||
|
||
/// <summary> | ||
/// The AWS account ID of the caller | ||
/// </summary> | ||
public string AccountId { get; set; } | ||
|
||
/// <summary> | ||
/// The Amazon Cognito identity pool ID associated with the caller | ||
/// </summary> | ||
public string CognitoIdentityPoolId { get; set; } | ||
|
||
/// <summary> | ||
/// The Amazon Cognito identity ID of the caller | ||
/// </summary> | ||
public string CognitoIdentityId { get; set; } | ||
|
||
/// <summary> | ||
/// The ARN of the IAM user | ||
/// </summary> | ||
public string UserArn { get; set; } | ||
|
||
/// <summary> | ||
/// Either authenticated or unauthenticated based on the identity type | ||
/// </summary> | ||
public string CognitoIdentityAuthType { get; set; } | ||
|
||
/// <summary> | ||
/// A comma separated list of external identity provider information used in obtaining the credentials used to sign the request | ||
/// </summary> | ||
public string CognitoIdentityAuthProvider { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Amazon.Lambda.AppSyncEvents | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use top level statement There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
{ | ||
/// <summary> | ||
/// Represents AWS LAMBDA authorization identity for AppSync | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: why is "LAMBDA" all caps? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fixed |
||
/// </summary> | ||
public class AppSyncLambdaIdentity | ||
{ | ||
/// <summary> | ||
/// Optional context information that will be passed to subsequent resolvers | ||
/// Can contain user information, claims, or any other contextual data | ||
/// </summary> | ||
public Dictionary<string, string> ResolverContext { get; set; } | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using System.Collections.Generic; | ||
|
||
namespace Amazon.Lambda.AppSyncEvents | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: use top level statement There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Updated |
||
{ | ||
/// <summary> | ||
/// Represents OPENID CONNECT authorization identity for AppSync | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: why is "OPENID CONNECT" all caps? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed |
||
/// </summary> | ||
public class AppSyncOidcIdentity | ||
{ | ||
/// <summary> | ||
/// Claims from the OIDC token as key-value pairs | ||
/// </summary> | ||
public Dictionary<string, object> Claims { get; set; } | ||
|
||
/// <summary> | ||
/// The issuer of the OIDC token | ||
/// </summary> | ||
public string Issuer { get; set; } | ||
|
||
/// <summary> | ||
/// The UUID of the authenticated user | ||
/// </summary> | ||
public string Sub { get; set; } | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: fix indentation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed