-
Notifications
You must be signed in to change notification settings - Fork 239
feat: V1 and V2 of the API Gateway custom authorizer event and the si… #166
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
a7e7113
feat: V1 and V2 of the API Gateway custom authorizer event and the si…
msailes 2e6bd0c
Added get functions to provide a better dev experience.
msailes afc30d9
removing comment
msailes 41ad4b1
feat: V1 and V2 of the API Gateway custom authorizer event and the si…
msailes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...in/java/com/amazonaws/services/lambda/runtime/events/APIGatewayCustomAuthorizerEvent.java
This file contains hidden or 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,59 @@ | ||
package com.amazonaws.services.lambda.runtime.events; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* The API Gateway customer authorizer event object as described - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html | ||
* | ||
*/ | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class APIGatewayCustomAuthorizerEvent { | ||
|
||
private String version; | ||
private String type; | ||
private String methodArn; | ||
private String identitySource; | ||
private String authorizationToken; | ||
private String resource; | ||
private String path; | ||
private String httpMethod; | ||
private Map<String, String> headers; | ||
private Map<String, String> queryStringParameters; | ||
private Map<String, String> pathParameters; | ||
private Map<String, String> stageVariables; | ||
private RequestContext requestContext; | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class RequestContext { | ||
private String path; | ||
private String accountId; | ||
private String resourceId; | ||
private String stage; | ||
private String requestId; | ||
private Identity identity; | ||
private String resourcePath; | ||
private String httpMethod; | ||
private String apiId; | ||
} | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Identity { | ||
private String apiKey; | ||
private String sourceIp; | ||
} | ||
} |
66 changes: 66 additions & 0 deletions
66
.../java/com/amazonaws/services/lambda/runtime/events/APIGatewayV2CustomAuthorizerEvent.java
This file contains hidden or 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,66 @@ | ||
package com.amazonaws.services.lambda.runtime.events; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
/** | ||
* The V2 API Gateway customer authorizer event object as described - https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html | ||
* | ||
*/ | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class APIGatewayV2CustomAuthorizerEvent { | ||
|
||
private String version; | ||
private String type; | ||
private String routeArn; | ||
private List<String> identitySource; | ||
private String routeKey; | ||
private String rawPath; | ||
private String rawQueryString; | ||
private List<String> cookies; | ||
private Map<String, String> headers; | ||
private Map<String, String> queryStringParameters; | ||
private RequestContext requestContext; | ||
private Map<String, String> pathParameters; | ||
private Map<String, String> stageVariables; | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class RequestContext { | ||
|
||
private String accountId; | ||
private String apiId; | ||
private String domainName; | ||
private String domainPrefix; | ||
private Http http; | ||
private String requestId; | ||
private String routeKey; | ||
private String stage; | ||
private String time; // "time": "12/Mar/2020:19:03:58 +0000", | ||
private int timeEpoch; | ||
} | ||
|
||
@AllArgsConstructor | ||
@Builder(setterPrefix = "with") | ||
@Data | ||
@NoArgsConstructor | ||
public static class Http { | ||
|
||
private String method; | ||
private String path; | ||
private String protocol; | ||
private String sourceIp; | ||
private String userAgent; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...va-events/src/main/java/com/amazonaws/services/lambda/runtime/events/SimpleIAMPolicy.java
This file contains hidden or 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,23 @@ | ||
package com.amazonaws.services.lambda.runtime.events; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.Map; | ||
|
||
/** | ||
* The simplified IAM Policy response object as described in https://docs.aws.amazon.com/apigateway/latest/developerguide/http-api-lambda-authorizer.html | ||
* | ||
*/ | ||
|
||
@Data | ||
@Builder(setterPrefix = "with") | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class SimpleIAMPolicy { | ||
|
||
private boolean isAuthorized; | ||
private Map<String, String> context; | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Can this be an object?
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.
This might be better off as a
ZonedDateTime
objectThere 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.
Apologies,
ZonedDateTime
(de)serialization is not currently supported in the Java runtimes, eitherString
ororg.joda.time.DateTime
(currently preferred) should be fine.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.
it is possible to write a custom
StdDeserializer
to achieve this, but we dont want to do that ? 🤔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.
Unfortunately registering a custom mapper in this library is not currently supported by the Java runtime and this is probably the best solution we can implement at this time IMHO