-
Notifications
You must be signed in to change notification settings - Fork 1
/
http-ext-metadata-geofence.yaml
46 lines (45 loc) · 1.09 KB
/
http-ext-metadata-geofence.yaml
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
apiVersion: authorino.kuadrant.io/v1beta1
kind: AuthConfig
metadata:
name: talker-api-protection
spec:
hosts:
- talker-api.127.0.0.1.nip.io
identity:
- name: friends
apiKey:
selector:
matchLabels:
group: friends
credentials:
in: authorization_header
keySelector: APIKEY
metadata:
- name: geo
http:
endpoint: http://ip-api.com/json/{context.request.http.headers.x-forwarded-for.@extract:{"sep":","}}?fields=countryCode
method: GET
headers:
- name: Accept
value: application/json
authorization:
- name: geofence
opa:
inlineRego: |
import input.context.request.http
allow {
http.method = "GET"
split(http.path, "/") = [_, requested_country, _]
lower(requested_country) == lower(object.get(input.auth.metadata.geo, "countryCode", ""))
}
---
apiVersion: v1
kind: Secret
metadata:
name: api-key-1
labels:
authorino.kuadrant.io/managed-by: authorino
group: friends
stringData:
api_key: ndyBzreUzF4zqDQsqSPMHkRhriEOtcRx
type: Opaque