-
Notifications
You must be signed in to change notification settings - Fork 46
Expand file tree
/
Copy pathapi.template.xml
More file actions
119 lines (118 loc) · 4.43 KB
/
api.template.xml
File metadata and controls
119 lines (118 loc) · 4.43 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="api">
<Description />
<FaultRules>
<FaultRule name="handle_FailedToResolveApiKey">
<Step>
<Name>rewrite-missing-key-message</Name>
</Step>
<Condition>(fault.name = "FailedToResolveAPIKey")</Condition>
</FaultRule>
<FaultRule name="handle_Response405WithoutAllowHeader">
<Step>
<Name>rewrite-missing-allow-header-error</Name>
</Step>
<Condition>(fault.name = "Response405WithoutAllowHeader")</Condition>
</FaultRule>
<FaultRule name="handle_QuotaExceeded">
<Condition>(fault.name = "QuotaViolation")</Condition>
<Step>
<Name>rewrite-quota-exceeded-message</Name>
</Step>
</FaultRule>
</FaultRules>
<PreFlow name="PreFlow">
<Request>
<Step>
<Condition>(request.header.x-api-key = null) and (request.queryparam.key != null)</Condition>
<Name>copy-key-param-to-header</Name>
</Step>
</Request>
<Response />
</PreFlow>
<Flows>
<Flow name="EnforceRestrictions">
<Request>
<Step>
<Condition>
<!-- List of endpoints that do NOT require a key -->
!(
(proxy.pathsuffix MatchesPath "/bulk/stats") OR
(proxy.pathsuffix MatchesPath "/internal/bio") OR
(proxy.pathsuffix MatchesPath "/node/places-in") OR
(proxy.pathsuffix MatchesPath "/node/property-labels") OR
(proxy.pathsuffix MatchesPath "/node/property-values") OR
(proxy.pathsuffix MatchesPath "/node/triples") OR
(proxy.pathsuffix MatchesPath "/place/stat-vars") OR
(proxy.pathsuffix MatchesPath "/place/stat/date/within-place") OR
(proxy.pathsuffix MatchesPath "/query") OR
(proxy.pathsuffix MatchesPath "/search") OR
(proxy.pathsuffix MatchesPath "/stat/all") OR
(proxy.pathsuffix MatchesPath "/stat/series") OR
(proxy.pathsuffix MatchesPath "/stat/value") OR
(proxy.pathsuffix MatchesPath "/v1/place/ranking") OR
(proxy.pathsuffix MatchesPath "/v1/place/related") OR
(proxy.pathsuffix MatchesPath "/v1/place/stat-vars/union") OR
(proxy.pathsuffix MatchesPath "/v1/recon/entity/resolve") OR
(proxy.pathsuffix MatchesPath "/v1/recon/resolve/coordinate") OR
(proxy.pathsuffix MatchesPath "/v1/recon/resolve/id") OR
(proxy.pathsuffix MatchesPath "/v1/stat/date/within-place") OR
(proxy.pathsuffix MatchesPath "/v1/variable/search") OR
(proxy.pathsuffix MatchesPath "/v2/resolve") OR
(proxy.pathsuffix MatchesPath "/version") OR
(proxy.pathsuffix MatchesPath "/healthz")
)
</Condition>
<Name>verify-api-key-in-header</Name>
</Step>
<Step>
<Condition>
(client_id != null) AND
(client_id != "")
</Condition>
<Name>set-quota-tier</Name>
</Step>
<Step>
<Condition>
(client_id != null) AND
(client_id != "") AND
(client_id = "REPLACE_WITH_TRIAL_API_KEY") AND
<!-- Disable if enforce-quota-limit-v2 is enabled -->
<!-- TODO: remove after enforce-quota-limit-v2 is fully enabled -->
! (datacommons_enforce_quota != null AND datacommons_enforce_quota = "true")
</Condition>
<Name>enforce-quota-limit</Name>
</Step>
<Step>
<Condition>
(datacommons_enforce_quota != null) AND
(datacommons_enforce_quota = "true")
</Condition>
<Name>enforce-quota-limit-v2</Name>
</Step>
</Request>
</Flow>
</Flows>
<PostFlow name="PostFlow">
<Request>
<Step>
<Name>strip-api-key-header-and-params</Name>
</Step>
<Step>
<Condition>
<!-- /healthz only works when a key is NOT present --> !(proxy.pathsuffix MatchesPath "/healthz") </Condition>
<Name>set-southbound-key</Name>
</Step>
</Request>
<Response />
</PostFlow>
<HTTPTargetConnection>
<Properties>
<Property name="response.streaming.enabled">true</Property>
</Properties>
<URL>https://REPLACE_WITH_MIXER_API_ESP_HOSTNAME</URL>
<SSLInfo>
<Enabled>true</Enabled>
</SSLInfo>
</HTTPTargetConnection>
</TargetEndpoint>