File tree Expand file tree Collapse file tree 2 files changed +29
-13
lines changed
Expand file tree Collapse file tree 2 files changed +29
-13
lines changed Original file line number Diff line number Diff line change @@ -113,6 +113,8 @@ metadata:
113113
114114The following section describes how to use this plugin with Open Policy Agent (OPA)
115115
116+ 
117+
116118### OPA input payload
117119
118120The plugin will translate the HTTP request (including headers and parameters) and forwards the payload as JSON to OPA.
@@ -180,28 +182,27 @@ and that the user has the required claims in the token.
180182
181183The policy below shows an simplified example :
182184
183- ` ` ` config
185+ ` ` ` rego
184186package example
185187
186- default allow = false
188+ import future.keywords.in
189+ import future.keywords.if
187190
188- allow {
189- input.method = "GET"
190- input.path[0] = "public"
191- }
191+ default allow := false
192192
193- allow {
194- input.method = "GET"
195- input.path = [ "secure", i ]
196- has_token([ "123", "456"])
193+ allow if {
194+ input.method == "GET"
195+ input.path[0] == "public"
197196}
198197
199- has_token(tokens) {
200- input.path[1] = tokens[i]
198+ allow if {
199+ input.method == "GET"
200+ input.path[0] == "secure"
201+ input.path[1] in {"123", "456"}
201202}
202203` ` `
203204
204- In the above example, requesting `/public/anything` or `/secure/123` is allowed,
205+ In the above example, requesting `/public/anything` or `/secure/123` or `/secure/456` is allowed,
205206however requesting `/secure/xxx` would be rejected and results in a 403 Forbidden.
206207
207208# # License
Original file line number Diff line number Diff line change 1+ @startuml
2+ actor User
3+ component "Load Balancer" as lb
4+ component "Trefik with\ntraefik-jwt-plugin" as t
5+ component "OPA" as opa
6+ component "Microservice" as ms
7+ User -right -> lb
8+ User <-right - lb
9+ lb -right -> t
10+ lb <-right - t
11+ t -down -> opa
12+ t <-down - opa
13+ t -right -> ms
14+ t <-right - ms
15+ @enduml
You can’t perform that action at this time.
0 commit comments