@@ -22,56 +22,58 @@ import AWSLambdaRuntime
2222// This code is shown for the example only and is not used in this demo.
2323// This code doesn't perform any type of token validation. It should be used as a reference only.
2424let policyAuthorizerHandler :
25- @Sendable ( APIGatewayLambdaAuthorizerRequest, LambdaContext) async throws -> APIGatewayLambdaAuthorizerPolicyResponse = {
26- ( request: APIGatewayLambdaAuthorizerRequest , context: LambdaContext ) in
25+ @Sendable ( APIGatewayLambdaAuthorizerRequest, LambdaContext) async throws ->
26+ APIGatewayLambdaAuthorizerPolicyResponse = {
27+ ( request: APIGatewayLambdaAuthorizerRequest , context: LambdaContext ) in
2728
28- context. logger. debug ( " +++ Policy Authorizer called +++ " )
29+ context. logger. debug ( " +++ Policy Authorizer called +++ " )
2930
30- // typically, this function will check the validity of the incoming token received in the request
31+ // typically, this function will check the validity of the incoming token received in the request
3132
32- // then it creates and returns a response
33- return APIGatewayLambdaAuthorizerPolicyResponse (
34- principalId: " John Appleseed " ,
33+ // then it creates and returns a response
34+ return APIGatewayLambdaAuthorizerPolicyResponse (
35+ principalId: " John Appleseed " ,
3536
36- // this policy allows the caller to invoke any API Gateway endpoint
37- policyDocument: . init( statement: [
38- . init(
39- action: " execute-api:Invoke " ,
40- effect: . allow,
41- resource: " * "
42- )
37+ // this policy allows the caller to invoke any API Gateway endpoint
38+ policyDocument: . init( statement: [
39+ . init(
40+ action: " execute-api:Invoke " ,
41+ effect: . allow,
42+ resource: " * "
43+ )
4344
44- ] ) ,
45+ ] ) ,
4546
46- // this is additional context we want to return to the caller
47- context: [
48- " abc1 " : " xyz1 " ,
49- " abc2 " : " xyz2 " ,
50- ]
51- )
52- }
47+ // this is additional context we want to return to the caller
48+ context: [
49+ " abc1 " : " xyz1 " ,
50+ " abc2 " : " xyz2 " ,
51+ ]
52+ )
53+ }
5354
5455//
5556// This is an example of a simple authorizer that always authorizes the request.
5657// A simple authorizer returns a yes/no decision and optional context key-value pairs
5758//
5859// This code doesn't perform any type of token validation. It should be used as a reference only.
5960let simpleAuthorizerHandler :
60- @Sendable ( APIGatewayLambdaAuthorizerRequest, LambdaContext) async throws -> APIGatewayLambdaAuthorizerSimpleResponse = {
61- ( _: APIGatewayLambdaAuthorizerRequest , context: LambdaContext ) in
61+ @Sendable ( APIGatewayLambdaAuthorizerRequest, LambdaContext) async throws ->
62+ APIGatewayLambdaAuthorizerSimpleResponse = {
63+ ( _: APIGatewayLambdaAuthorizerRequest , context: LambdaContext ) in
6264
63- context. logger. debug ( " +++ Simple Authorizer called +++ " )
65+ context. logger. debug ( " +++ Simple Authorizer called +++ " )
6466
65- // typically, this function will check the validity of the incoming token received in the request
67+ // typically, this function will check the validity of the incoming token received in the request
6668
67- return APIGatewayLambdaAuthorizerSimpleResponse (
68- // this is the authorization decision: yes or no
69- isAuthorized: true ,
69+ return APIGatewayLambdaAuthorizerSimpleResponse (
70+ // this is the authorization decision: yes or no
71+ isAuthorized: true ,
7072
71- // this is additional context we want to return to the caller
72- context: [ " abc1 " : " xyz1 " ]
73- )
74- }
73+ // this is additional context we want to return to the caller
74+ context: [ " abc1 " : " xyz1 " ]
75+ )
76+ }
7577
7678// create the runtime and start polling for new events.
7779// in this demo we use the simple authorizer handler
0 commit comments