@@ -22,56 +22,58 @@ import AWSLambdaRuntime
22
22
// This code is shown for the example only and is not used in this demo.
23
23
// This code doesn't perform any type of token validation. It should be used as a reference only.
24
24
let 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
27
28
28
- context. logger. debug ( " +++ Policy Authorizer called +++ " )
29
+ context. logger. debug ( " +++ Policy Authorizer called +++ " )
29
30
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
31
32
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 " ,
35
36
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
+ )
43
44
44
- ] ) ,
45
+ ] ) ,
45
46
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
+ }
53
54
54
55
//
55
56
// This is an example of a simple authorizer that always authorizes the request.
56
57
// A simple authorizer returns a yes/no decision and optional context key-value pairs
57
58
//
58
59
// This code doesn't perform any type of token validation. It should be used as a reference only.
59
60
let 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
62
64
63
- context. logger. debug ( " +++ Simple Authorizer called +++ " )
65
+ context. logger. debug ( " +++ Simple Authorizer called +++ " )
64
66
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
66
68
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 ,
70
72
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
+ }
75
77
76
78
// create the runtime and start polling for new events.
77
79
// in this demo we use the simple authorizer handler
0 commit comments