Skip to content

Commit c1ee678

Browse files
Merge pull request #13 from JohnRamberger/development
Development
2 parents 3bf2b2d + 14557ec commit c1ee678

File tree

141 files changed

+3577
-19
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

141 files changed

+3577
-19
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
## [Start] Authorization Steps. **
2+
$util.qr($ctx.stash.put("hasAuth", true))
3+
#set( $isAuthorized = false )
4+
#if( $util.authType() == "API Key Authorization" )
5+
6+
#end
7+
#if( $util.authType() == "IAM Authorization" )
8+
#set( $adminRoles = ["us-east-1_ooxChp1Q0_Full-access/CognitoIdentityCredentials","us-east-1_ooxChp1Q0_Manage-only/CognitoIdentityCredentials","hacklyticsportal20232e32fd51-staging","hacklyticsportal2023listusers-staging","hacklyticsportal2023checkinuser-staging"] )
9+
#foreach( $adminRole in $adminRoles )
10+
#if( $ctx.identity.userArn.contains($adminRole) && $ctx.identity.userArn != $ctx.stash.authRole && $ctx.identity.userArn != $ctx.stash.unauthRole )
11+
#return($util.toJson({}))
12+
#end
13+
#end
14+
$util.unauthorized()
15+
#end
16+
#if( $util.authType() == "User Pool Authorization" )
17+
#set( $isAuthorized = true )
18+
#if( !$isAuthorized )
19+
#set( $staticGroupRoles = [{"claim":"cognito:groups","entity":"Administrator"}] )
20+
#foreach( $groupRole in $staticGroupRoles )
21+
#set( $groupsInToken = $util.defaultIfNull($ctx.identity.claims.get($groupRole.claim), []) )
22+
#if( $groupsInToken.contains($groupRole.entity) )
23+
#set( $isAuthorized = true )
24+
#break
25+
#end
26+
#end
27+
#end
28+
#end
29+
#if( !$isAuthorized && $util.isNull($ctx.stash.authFilter) )
30+
$util.unauthorized()
31+
#end
32+
$util.toJson({"version":"2018-05-29","payload":{}})
33+
## [End] Authorization Steps. **
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## [Start] Invoke AWS Lambda data source: Hacklyticsportal20232e32fd51LambdaDataSource. **
2+
{
3+
"version": "2018-05-29",
4+
"operation": "Invoke",
5+
"payload": {
6+
"typeName": $util.toJson($ctx.stash.get("typeName")),
7+
"fieldName": $util.toJson($ctx.stash.get("fieldName")),
8+
"arguments": $util.toJson($ctx.arguments),
9+
"identity": $util.toJson($ctx.identity),
10+
"source": $util.toJson($ctx.source),
11+
"request": $util.toJson($ctx.request),
12+
"prev": $util.toJson($ctx.prev)
13+
}
14+
}
15+
## [End] Invoke AWS Lambda data source: Hacklyticsportal20232e32fd51LambdaDataSource. **
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## [Start] Handle error or return result. **
2+
#if( $ctx.error )
3+
$util.error($ctx.error.message, $ctx.error.type)
4+
#end
5+
$util.toJson($ctx.result)
6+
## [End] Handle error or return result. **
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
## [Start] Invoke AWS Lambda data source: Hacklyticsportal2023listusersLambdaDataSource. **
2+
{
3+
"version": "2018-05-29",
4+
"operation": "Invoke",
5+
"payload": {
6+
"typeName": $util.toJson($ctx.stash.get("typeName")),
7+
"fieldName": $util.toJson($ctx.stash.get("fieldName")),
8+
"arguments": $util.toJson($ctx.arguments),
9+
"identity": $util.toJson($ctx.identity),
10+
"source": $util.toJson($ctx.source),
11+
"request": $util.toJson($ctx.request),
12+
"prev": $util.toJson($ctx.prev)
13+
}
14+
}
15+
## [End] Invoke AWS Lambda data source: Hacklyticsportal2023listusersLambdaDataSource. **
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## [Start] Handle error or return result. **
2+
#if( $ctx.error )
3+
$util.error($ctx.error.message, $ctx.error.type)
4+
#end
5+
$util.toJson($ctx.result)
6+
## [End] Handle error or return result. **
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
## [Start] Authorization Steps. **
2+
$util.qr($ctx.stash.put("hasAuth", true))
3+
#set( $inputFields = $util.parseJson($util.toJson($ctx.args.input.keySet())) )
4+
#set( $isAuthorized = false )
5+
#set( $allowedFields = [] )
6+
#if( $util.authType() == "API Key Authorization" )
7+
$util.unauthorized()
8+
#end
9+
#if( $util.authType() == "IAM Authorization" )
10+
#set( $adminRoles = ["us-east-1_ooxChp1Q0_Full-access/CognitoIdentityCredentials","us-east-1_ooxChp1Q0_Manage-only/CognitoIdentityCredentials","hacklyticsportal20232e32fd51-staging","hacklyticsportal2023listusers-staging","hacklyticsportal2023checkinuser-staging"] )
11+
#foreach( $adminRole in $adminRoles )
12+
#if( $ctx.identity.userArn.contains($adminRole) && $ctx.identity.userArn != $ctx.stash.authRole && $ctx.identity.userArn != $ctx.stash.unauthRole )
13+
#return($util.toJson({}))
14+
#end
15+
#end
16+
$util.unauthorized()
17+
#end
18+
#if( $util.authType() == "User Pool Authorization" )
19+
#if( !$isAuthorized )
20+
#set( $staticGroupRoles = [{"claim":"cognito:groups","entity":"Administrator","allowedFields":["id","hacklyticsOpen","_version","_deleted","_lastChangedAt"],"isAuthorizedOnAllFields":true}] )
21+
#foreach( $groupRole in $staticGroupRoles )
22+
#set( $groupsInToken = $util.defaultIfNull($ctx.identity.claims.get($groupRole.claim), []) )
23+
#if( $groupsInToken.contains($groupRole.entity) )
24+
#if( $groupRole.isAuthorizedOnAllFields )
25+
#set( $isAuthorized = true )
26+
#break
27+
#else
28+
$util.qr($allowedFields.addAll($groupRole.allowedFields))
29+
#end
30+
#end
31+
#end
32+
#end
33+
#end
34+
#if( !$isAuthorized && $allowedFields.isEmpty() )
35+
$util.unauthorized()
36+
#end
37+
#if( !$isAuthorized )
38+
#set( $deniedFields = $util.list.copyAndRemoveAll($inputFields, $allowedFields) )
39+
#if( $deniedFields.size() > 0 )
40+
$util.error("Unauthorized on ${deniedFields}", "Unauthorized")
41+
#end
42+
#end
43+
$util.toJson({"version":"2018-05-29","payload":{}})
44+
## [End] Authorization Steps. **
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
## [Start] Initialization default values. **
2+
$util.qr($ctx.stash.put("defaultValues", $util.defaultIfNull($ctx.stash.defaultValues, {})))
3+
#set( $createdAt = $util.time.nowISO8601() )
4+
$util.qr($ctx.stash.defaultValues.put("id", $util.autoId()))
5+
$util.qr($ctx.stash.defaultValues.put("createdAt", $createdAt))
6+
$util.qr($ctx.stash.defaultValues.put("updatedAt", $createdAt))
7+
$util.toJson({
8+
"version": "2018-05-29",
9+
"payload": {}
10+
})
11+
## [End] Initialization default values. **
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
## [Start] Sandbox Mode Disabled. **
2+
#if( !$ctx.stash.get("hasAuth") )
3+
$util.unauthorized()
4+
#end
5+
$util.toJson({})
6+
## [End] Sandbox Mode Disabled. **
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
## [Start] Create Request template. **
2+
#set( $args = $util.defaultIfNull($ctx.stash.transformedArgs, $ctx.args) )
3+
## Set the default values to put request **
4+
#set( $mergedValues = $util.defaultIfNull($ctx.stash.defaultValues, {}) )
5+
## copy the values from input **
6+
$util.qr($mergedValues.putAll($util.defaultIfNull($args.input, {})))
7+
## set the typename **
8+
$util.qr($mergedValues.put("__typename", "AdminSettings"))
9+
#set( $PutObject = {
10+
"version": "2018-05-29",
11+
"operation": "PutItem",
12+
"attributeValues": $util.dynamodb.toMapValues($mergedValues),
13+
"condition": $condition
14+
} )
15+
#if( $args.condition )
16+
$util.qr($ctx.stash.conditions.add($args.condition))
17+
#end
18+
## Begin - key condition **
19+
#if( $ctx.stash.metadata.modelObjectKey )
20+
#set( $keyConditionExpr = {} )
21+
#set( $keyConditionExprNames = {} )
22+
#foreach( $entry in $ctx.stash.metadata.modelObjectKey.entrySet() )
23+
$util.qr($keyConditionExpr.put("keyCondition$velocityCount", {
24+
"attributeExists": false
25+
}))
26+
$util.qr($keyConditionExprNames.put("#keyCondition$velocityCount", "$entry.key"))
27+
#end
28+
$util.qr($ctx.stash.conditions.add($keyConditionExpr))
29+
#else
30+
$util.qr($ctx.stash.conditions.add({
31+
"id": {
32+
"attributeExists": false
33+
}
34+
}))
35+
#end
36+
## End - key condition **
37+
## Start condition block **
38+
#if( $ctx.stash.conditions && $ctx.stash.conditions.size() != 0 )
39+
#set( $mergedConditions = {
40+
"and": $ctx.stash.conditions
41+
} )
42+
#set( $Conditions = $util.parseJson($util.transform.toDynamoDBConditionExpression($mergedConditions)) )
43+
#if( $Conditions.expressionValues && $Conditions.expressionValues.size() == 0 )
44+
#set( $Conditions = {
45+
"expression": $Conditions.expression,
46+
"expressionNames": $Conditions.expressionNames
47+
} )
48+
#end
49+
## End condition block **
50+
#end
51+
#if( $Conditions )
52+
#if( $keyConditionExprNames )
53+
$util.qr($Conditions.expressionNames.putAll($keyConditionExprNames))
54+
#end
55+
$util.qr($PutObject.put("condition", $Conditions))
56+
#end
57+
#if( $ctx.stash.metadata.modelObjectKey )
58+
$util.qr($PutObject.put("key", $ctx.stash.metadata.modelObjectKey))
59+
#else
60+
#set( $Key = {
61+
"id": $util.dynamodb.toDynamoDB($mergedValues.id)
62+
} )
63+
$util.qr($PutObject.put("key", $Key))
64+
#end
65+
$util.toJson($PutObject)
66+
## [End] Create Request template. **
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
## [Start] ResponseTemplate. **
2+
$util.qr($ctx.result.put("__operation", "Mutation"))
3+
#if( $ctx.error )
4+
$util.error($ctx.error.message, $ctx.error.type, $ctx.result)
5+
#else
6+
$util.toJson($ctx.result)
7+
#end
8+
## [End] ResponseTemplate. **

0 commit comments

Comments
 (0)