-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: rework eval policy and support setting headers to downstream req
- Loading branch information
Showing
5 changed files
with
82 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,6 +27,7 @@ providers: | |
} | ||
bypass_auth if { | ||
print("bypass", pre_authed) | ||
pre_authed | ||
} | ||
|
@@ -41,6 +42,11 @@ providers: | |
glob.match("/api/info", ["/"], httpreq.path) | ||
} | ||
action_allowed if { | ||
httpreq.method == "GET" | ||
glob.match("/headers", ["/"], httpreq.path) | ||
} | ||
action_allowed if { | ||
httpreq.method == "GET" | ||
print("request path:", httpreq.path) | ||
|
@@ -54,6 +60,10 @@ providers: | |
token.payload.email == "[email protected]" | ||
} | ||
headers["x-ext-authz-allow"] := "true" if { allow == true } | ||
headers["x-ext-authz-pre-policy"] := "true" | ||
headers["foo"] := "bar" | ||
jwks_request(url) := http.send({ | ||
"url": url, "method": "GET", "force_cache": true, "force_cache_duration_seconds": 3600 | ||
}) | ||
|
@@ -65,6 +75,13 @@ providers: | |
[_, payload, _] := io.jwt.decode(parsed_jwt) | ||
} | ||
valid_tenents := { "securityteam", "devteam", "foo", "bar" } | ||
token_payload_groups := [ "OpsTeam", "SecurityTeam" ] | ||
groups_set := { lower(x) | x := token_payload_groups[_] } | ||
groups := groups_set & valid_tenents | ||
headers["X-Scope-OrgID"] := concat("|", array.concat(["fake"], [ x | x := groups[_] ])) | ||
postAuthPolicy: | | ||
package authz | ||
import rego.v1 | ||
|
@@ -75,6 +92,10 @@ providers: | |
token.payload.email == "[email protected]" | ||
} | ||
headers["x-ext-authz-allow"] := "true" if { allow == true } | ||
headers["x-ext-authz-post-policy"] := "true" | ||
headers["foo"] := "baz" | ||
token := { "payload": payload } if { | ||
[_, payload, _] := io.jwt.decode(input.parsed_jwt) | ||
} | ||
|