-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathlambda-auth.js
More file actions
41 lines (41 loc) · 1.12 KB
/
lambda-auth.js
File metadata and controls
41 lines (41 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
exports.handler = function(event, context, callback) {
console.log('Received event:', JSON.stringify(event, null, 2));
if (event.headers.authorization === "secretToken") {
console.log("allowed");
callback(null,{
"principalId": "abcdef", // The principal user identification associated with the token sent by the client.
"policyDocument": {
"Version": "2012-10-17",
"Statement": [{
"Action": "execute-api:Invoke",
"Effect": "Allow",
"Resource": "*"
}]
},
"context": {
"stringKey": "value",
"numberKey": 1,
"booleanKey": true
}
});
}
else {
console.log("denied");
callback(null, {
"principalId": "abcdef", // The principal user identification associated with the token sent by the client.
"policyDocument": {
"Version": "2012-10-17",
"Statement": [{
"Action": "execute-api:Invoke",
"Effect": "Deny",
"Resource": "*"
}]
},
"context": {
"stringKey": "value",
"numberKey": 1,
"booleanKey": true
}
});
}
};