Skip to content

Commit

Permalink
Check iss, iat & exp when validating JWT in OPA policy
Browse files Browse the repository at this point in the history
  • Loading branch information
garryod committed Apr 2, 2024
1 parent 5e1eada commit 778f596
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions policy/token.rego
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,10 @@ jwks_url := concat("?", [jwks_endpoint, urlquery.encode_object({"kid": jwt_heade

jwks := fetch_jwks(jwks_url).raw_body

verified := unverified if {
io.jwt.verify_rs256(input.token, jwks)
}
valid := io.jwt.decode_verify(input.token, {
"cert": jwks,
"iss": "https://authn.diamond.ac.uk/realms/master",
"time": time.now_ns(),
})

claims := verified[1]
claims := valid[2]

0 comments on commit 778f596

Please sign in to comment.