Skip to content

fix: update CognitoUserPoolPreTokenGenerationEventV2 response model #519

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 7 commits into from
Feb 4, 2025
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
19 changes: 16 additions & 3 deletions .github/workflows/samples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,24 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
# Set up both Java 8 and 21
- name: Set up Java 8 and 21
uses: actions/setup-java@v4
with:
java-version: 21
java-version: |
8
21
distribution: corretto

# Install events module using Java 8
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we verified that we need this change? Does CI still pass when we revert this modification?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it doesn't pass. The above CI runs are examples of experiments I tried to make it work with Java 21 (didn't work). The issue is that the event package has it's compiler set to Java 8, hence this looks like a forced move.
image

- name: Install events with Maven
run: |
export JAVA_HOME=$JAVA_HOME_8_X64
mvn -B clean install \
-Dmaven.compiler.source=1.8 \
-Dmaven.compiler.target=1.8 \
--file aws-lambda-java-events/pom.xml

# Build custom-serialization samples
- name: install sam
uses: aws-actions/setup-sam@v2
Expand All @@ -57,4 +71,3 @@ jobs:
run: cd samples/custom-serialization/moshi && sam build && sam local invoke -e events/event.json | grep 200
- name: test request-stream-handler
run: cd samples/custom-serialization/request-stream-handler && sam build && sam local invoke -e events/event.json | grep 200

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public class SqsHandler implements RequestHandler<SQSEvent, String> {
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.14.0</version>
<version>3.15.0</version>
</dependency>
```

Expand Down
3 changes: 2 additions & 1 deletion aws-lambda-java-events/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
* `CognitoUserPoolPreAuthenticationEvent`
* `CognitoUserPoolPreSignUpEvent`
* `CognitoUserPoolPreTokenGenerationEvent`
* `CognitoUserPoolPreTokenGenerationEventV2`
* `CognitoUserPoolVerifyAuthChallengeResponseEvent`
* `ConfigEvent`
* `ConnectEvent`
Expand Down Expand Up @@ -73,7 +74,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.14.0</version>
<version>3.15.0</version>
</dependency>
...
</dependencies>
Expand Down
4 changes: 4 additions & 0 deletions aws-lambda-java-events/RELEASE.CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
### January 31, 2025
`3.15.0`:
- Fix `CognitoUserPoolPreTokenGenerationEventV2` model ([#519](https://github.com/aws/aws-lambda-java-libs/pull/519))

### September 13, 2024
`3.14.0`:
- Fix name of s3Bucket field of Task class in S3BatchEventV2 ([#506](https://github.com/aws/aws-lambda-java-libs/pull/506))
Expand Down
2 changes: 1 addition & 1 deletion aws-lambda-java-events/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.14.0</version>
<version>3.15.0</version>
<packaging>jar</packaging>

<name>AWS Lambda Java Events Library</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public static class AccessTokenGeneration {
@Builder(setterPrefix = "with")
@NoArgsConstructor
public static class GroupOverrideDetails {
private Map<String, String> groupsToOverride;
private Map<String, String> iamRolesToOverride;
private String[] groupsToOverride;
private String[] iamRolesToOverride;
private String preferredRole;
}
}
2 changes: 1 addition & 1 deletion aws-lambda-java-tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.14.0</version>
<version>3.15.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,17 @@ public void testLoadCognitoUserPoolPreTokenGenerationEventV2() {
CognitoUserPoolPreTokenGenerationEventV2.Request request = event.getRequest();
String[] requestScopes = request.getScopes();
assertThat("aws.cognito.signin.user.admin").isEqualTo(requestScopes[0]);

CognitoUserPoolPreTokenGenerationEventV2.Response response = event.getResponse();
String[] groupsToOverride = response.getClaimsAndScopeOverrideDetails().getGroupOverrideDetails().getGroupsToOverride();
String[] iamRolesToOverride = response.getClaimsAndScopeOverrideDetails().getGroupOverrideDetails().getIamRolesToOverride();
String preferredRole = response.getClaimsAndScopeOverrideDetails().getGroupOverrideDetails().getPreferredRole();

assertThat("group-99").isEqualTo(groupsToOverride[0]);
assertThat("group-98").isEqualTo(groupsToOverride[1]);
assertThat("arn:aws:iam::123456789012:role/sns_caller99").isEqualTo(iamRolesToOverride[0]);
assertThat("arn:aws:iam::123456789012:role/sns_caller98").isEqualTo(iamRolesToOverride[1]);
assertThat("arn:aws:iam::123456789012:role/sns_caller_99").isEqualTo(preferredRole);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@
"groupConfiguration": {
"groupsToOverride": ["group-1", "group-2", "group-3"],
"iamRolesToOverride": ["arn:aws:iam::123456789012:role/sns_caller1", "arn:aws:iam::123456789012:role/sns_caller2", "arn:aws:iam::123456789012:role/sns_caller3"],
"preferredRole": ["arn:aws:iam::123456789012:role/sns_caller"]
"preferredRole": "arn:aws:iam::123456789012:role/sns_caller"
},
"scopes": [
"aws.cognito.signin.user.admin", "openid", "email", "phone"
]
},
"response": {
"claimsAndScopeOverrideDetails": []
"claimsAndScopeOverrideDetails": {
"groupOverrideDetails": {
"groupsToOverride": ["group-99", "group-98"],
"iamRolesToOverride": ["arn:aws:iam::123456789012:role/sns_caller99", "arn:aws:iam::123456789012:role/sns_caller98"],
"preferredRole": "arn:aws:iam::123456789012:role/sns_caller_99"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.14.0</version>
<version>3.15.0</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.14.0</version>
<version>3.15.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.14.0</version>
<version>3.15.0</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.14.0</version>
<version>3.15.0</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand Down
2 changes: 1 addition & 1 deletion samples/kinesis-firehose-event-handler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-lambda-java-events</artifactId>
<version>3.14.0</version>
<version>3.15.0</version>
</dependency>

<dependency>
Expand Down