Skip to content

Commit 2b7361f

Browse files
committed
Rebasing and updating iot events since the contract has chagned
1 parent 8618920 commit 2b7361f

File tree

5 files changed

+38
-16
lines changed

5 files changed

+38
-16
lines changed

events/apigw.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,10 +253,3 @@ type APIGatewayCustomAuthorizerPolicy struct {
253253
Version string
254254
Statement []IAMPolicyStatement
255255
}
256-
257-
// IAMPolicyStatement represents one statement from IAM policy with action, effect and resource
258-
type IAMPolicyStatement struct {
259-
Action []string
260-
Effect string
261-
Resource []string
262-
}

events/iam.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package events
22

3+
// IAMPolicyStatement represents one statement from IAM policy with action, effect and resource
34
type IAMPolicyStatement struct {
45
Action []string
56
Effect string

events/iot.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,26 @@ package events
22

33
// IoTCustomAuthorizerRequest contains data coming in to a custom IoT device gateway authorizer function.
44
type IoTCustomAuthorizerRequest struct {
5-
AuthorizationToken string `json:"token"`
5+
HttpContext *IoTHttpContext `json:"httpContext,omitempty"`
6+
MqttContext *IoTMqttContext `json:"mqttContext,omitempty"`
7+
TlsContext *IotTlsContext `json:"tlsContext,omitempty"`
8+
AuthorizationToken string `json:"token"`
9+
TokenSignature string `json:"tokenSignature"`
10+
}
11+
12+
type IoTHttpContext struct {
13+
Headers map[string]string `json:"headers,omitempty"`
14+
QueryString string `json:"queryString"`
15+
}
16+
17+
type IoTMqttContext struct {
18+
ClientId string `json:"clientId"`
19+
Password []byte `json:"password"`
20+
Username string `json:"username"`
21+
}
22+
23+
type IotTlsContext struct {
24+
ServerName string `json:"serverName"`
625
}
726

827
// IoTCustomAuthorizerResponse represents the expected format of an IoT device gateway authorization response.
@@ -12,7 +31,6 @@ type IoTCustomAuthorizerResponse struct {
1231
DisconnectAfterInSeconds int32 `json:"disconnectAfterInSeconds"`
1332
RefreshAfterInSeconds int32 `json:"refreshAfterInSeconds"`
1433
PolicyDocuments []string `json:"policyDocuments"`
15-
Context map[string]interface{} `json:"context,omitempty"`
1634
}
1735

1836
// IoTCustomAuthorizerPolicy represents an IAM policy. PolicyDocuments is an array of IoTCustomAuthorizerPolicy JSON strings
Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
{
2-
"token":"allow"
2+
"httpContext": {
3+
"headers": {
4+
"Accept-Language" : "en"
5+
},
6+
"queryString": "abc"
7+
},
8+
"mqttContext": {
9+
"clientId": "someclient",
10+
"password": "aslkfjwoeiuwekrujwlrueowieurowieurowiuerwleuroiwueroiwueroiuweoriuweoriuwoeiruwoeiur",
11+
"username": "thebestuser"
12+
},
13+
"tlsContext": {
14+
"serverName": "server.stuff.com"
15+
},
16+
"token": "someToken",
17+
"tokenSignature": "somelongtokensignature"
318
}

events/testdata/iot-custom-auth-response.json

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,5 @@
55
"refreshAfterInSeconds": 300,
66
"policyDocuments": [
77
"{ \"Version\": \"2012-10-17\", \"Statement\": [ { \"Action\": [\"iot:Subscribe\"], \"Effect\": \"Allow\", \"Resource\": [\"*\"] } ] }"
8-
],
9-
"context": {
10-
"username" : "johnDoe123",
11-
"city" : "Seattle",
12-
"country" : "USA"
13-
}
8+
]
149
}

0 commit comments

Comments
 (0)