Skip to content

Commit 19d5ccb

Browse files
msailesandclt
authored andcommitted
Adds the V2 version of the pre token generation event.
1 parent 02d2c06 commit 19d5ccb

File tree

1 file changed

+134
-0
lines changed

1 file changed

+134
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,134 @@
1+
/* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. */
2+
3+
package com.amazonaws.services.lambda.runtime.events;
4+
5+
import lombok.AllArgsConstructor;
6+
import lombok.Builder;
7+
import lombok.Data;
8+
import lombok.EqualsAndHashCode;
9+
import lombok.NoArgsConstructor;
10+
import lombok.ToString;
11+
12+
import java.util.Map;
13+
14+
/**
15+
* Represent the class for the Cognito User Pool Pre Token Generation Lambda Trigger V2
16+
* <p>
17+
* See <a href="https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-lambda-pre-token-generation.html">Pre Token Generation Lambda Trigger</a>
18+
*/
19+
@Data
20+
@EqualsAndHashCode(callSuper = true)
21+
@NoArgsConstructor
22+
@ToString(callSuper = true)
23+
public class CognitoUserPoolPreTokenGenerationEventV2 extends CognitoUserPoolEvent {
24+
/**
25+
* The request from the Amazon Cognito service.
26+
*/
27+
private Request request;
28+
29+
/**
30+
* The response from your Lambda trigger.
31+
*/
32+
private Response response;
33+
34+
@Builder(setterPrefix = "with")
35+
public CognitoUserPoolPreTokenGenerationEventV2(
36+
String version,
37+
String triggerSource,
38+
String region,
39+
String userPoolId,
40+
String userName,
41+
CallerContext callerContext,
42+
Request request,
43+
Response response) {
44+
super(version, triggerSource, region, userPoolId, userName, callerContext);
45+
this.request = request;
46+
this.response = response;
47+
}
48+
49+
@Data
50+
@EqualsAndHashCode(callSuper = true)
51+
@NoArgsConstructor
52+
@ToString(callSuper = true)
53+
public static class Request extends CognitoUserPoolEvent.Request {
54+
55+
private String[] scopes;
56+
private GroupConfiguration groupConfiguration;
57+
private Map<String, String> clientMetadata;
58+
59+
@Builder(setterPrefix = "with")
60+
public Request(Map<String, String> userAttributes, String[] scopes, GroupConfiguration groupConfiguration, Map<String, String> clientMetadata) {
61+
super(userAttributes);
62+
this.scopes = scopes;
63+
this.groupConfiguration = groupConfiguration;
64+
this.clientMetadata = clientMetadata;
65+
}
66+
}
67+
68+
@Data
69+
@AllArgsConstructor
70+
@Builder(setterPrefix = "with")
71+
@NoArgsConstructor
72+
public static class GroupConfiguration {
73+
/**
74+
* A list of the group names that are associated with the user that the identity token is issued for.
75+
*/
76+
private String[] groupsToOverride;
77+
/**
78+
* A list of the current IAM roles associated with these groups.
79+
*/
80+
private String[] iamRolesToOverride;
81+
/**
82+
* Indicates the preferred IAM role.
83+
*/
84+
private String preferredRole;
85+
}
86+
87+
@Data
88+
@AllArgsConstructor
89+
@Builder(setterPrefix = "with")
90+
@NoArgsConstructor
91+
public static class Response {
92+
private ClaimsAndScopeOverrideDetails claimsAndScopeOverrideDetails;
93+
}
94+
95+
@Data
96+
@AllArgsConstructor
97+
@Builder(setterPrefix = "with")
98+
@NoArgsConstructor
99+
public static class ClaimsAndScopeOverrideDetails {
100+
private IdTokenGeneration idTokenGeneration;
101+
private AccessTokenGeneration accessTokenGeneration;
102+
private GroupOverrideDetails groupOverrideDetails;
103+
}
104+
105+
@Data
106+
@AllArgsConstructor
107+
@Builder(setterPrefix = "with")
108+
@NoArgsConstructor
109+
public static class IdTokenGeneration {
110+
private Map<String, String> claimsToAddOrOverride;
111+
private String[] claimsToSuppress;
112+
}
113+
114+
@Data
115+
@AllArgsConstructor
116+
@Builder(setterPrefix = "with")
117+
@NoArgsConstructor
118+
public static class AccessTokenGeneration {
119+
private Map<String, String> claimsToAddOrOverride;
120+
private String[] claimsToSuppress;
121+
private String[] scopesToAdd;
122+
private String[] scopesToSuppress;
123+
}
124+
125+
@Data
126+
@AllArgsConstructor
127+
@Builder(setterPrefix = "with")
128+
@NoArgsConstructor
129+
public static class GroupOverrideDetails {
130+
private Map<String, String> groupsToOverride;
131+
private Map<String, String> iamRolesToOverride;
132+
private String preferredRole;
133+
}
134+
}

0 commit comments

Comments
 (0)