Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"command": "data.graph_reachable_example.result"
"showInput": false,
"showData": false,
"showTitles": false,
"titleSize": 5,
"command": "data.graph_reachable_example.result"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
A common class of recursive rules can be reduced to a graph reachability
problem, so `graph.reachable` is useful for more than just graph analysis.
This usually requires some pre- and postprocessing. The following example
shows you how to "flatten" a hierarchy of access permissions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Graph Reachable
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"command": "data.graph_reachable_paths_example.result"
"showInput": false,
"showData": false,
"showTitles": false,
"titleSize": 5,
"command": "data.graph_reachable_paths_example.result"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
It may be useful to find all reachable paths from a root element. `graph.reachable_paths` can be used for this. Note that cyclical paths will terminate on the repeated node. If an element references a nonexistent element, the path will be terminated, and excludes the nonexistent node.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Graph Reachable Paths

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"titleSize": 5,
"command": "data.netcidrcontainsmatches.result"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Either (or both) operand(s) may be an array, set, or object.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CIDR Match with Array
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"titleSize": 5,
"command": "data.netcidrcontainsmatches.result"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The array/set/object elements may be arrays. In that case, the first element must be a valid CIDR/IP.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CIDR Match with Arrays
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"titleSize": 5,
"command": "data.netcidrcontainsmatches.result"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
If the operand is a set, the outputs are matching elements. If the operand is an object, the outputs are matching keys.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CIDR Match with Objects
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"titleSize": 5,
"command": "data.netcidrcontainsmatches.result"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
If both operands are string values the function is similar to `net.cidr_contains`.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
CIDR Match with String Ranges
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"showInput": true,
"showData": false,
"showTitles": false,
"command": "data.example"
"showInput": true,
"showData": false,
"showTitles": false,
"titleSize": 5,
"command": "data.example"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
The following policy will deny the given input because:

- the `number` is greater than 5
- the `subject` does not have the `admin` role
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Rule Metadata
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"command": "data.semverisvalid"
"showInput": false,
"showData": false,
"showTitles": false,
"titleSize": 5,
"command": "data.semverisvalid"
}
8 changes: 8 additions & 0 deletions docs/docs/policy-reference/_examples/semver/isvalid/intro.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
The `result := semver.is_valid(vsn)` function checks to see if a version
string is of the form: `MAJOR.MINOR.PATCH[-PRERELEASE][+METADATA]`, where
items in square braces are optional elements.

:::warning
When working with Go-style semantic versions, remember to remove the
leading `v` character, or the semver string will be marked as invalid!
:::
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Example of semver.is_valid
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"command": "data.time_format"
"showInput": false,
"showData": false,
"showTitles": false,
"command": "data.time_format",
"titleSize": 5
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
In OPA, we can parse a simple YYYY-MM-DD timestamp as follows:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Timestamp Parsing
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"command": "data.jwt.result"
"showInput": false,
"showData": false,
"showTitles": false,
"titleSize": 5,
"command": "data.jwt.result"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Symmetric Key with empty JSON payload
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"command": "data.jwt.result"
"showInput": false,
"showData": false,
"showTitles": false,
"titleSize": 5,
"command": "data.jwt.result"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Symmetric Key (HMAC with SHA-256)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"command": "data.jwt.result"
"showInput": false,
"showData": false,
"showTitles": false,
"titleSize": 5,
"command": "data.jwt.result"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
RSA Key (RSA Signature with SHA-256)
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"command": "data.jwt.result"
"showInput": false,
"showData": false,
"showTitles": false,
"titleSize": 5,
"command": "data.jwt.result"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
If you need to generate the signature for a serialized token you an use the
`io.jwt.encode_sign_raw` built-in function which accepts JSON serialized string
parameters.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Raw Token Signing
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"showPlayground": false,
"command": "data.jwt"
"showInput": false,
"showData": false,
"showTitles": false,
"showPlayground": false,
"titleSize": 5,
"command": "data.jwt"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This example shows a two-step process to verify the token signature and then decode it for
further checks of the payload content. This approach gives more flexibility in verifying only
the claims that the policy needs to enforce.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Certificate Verify
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"showPlayground": false,
"command": "data.jwt"
"showInput": false,
"showData": false,
"showTitles": false,
"showPlayground": false,
"titleSize": 5,
"command": "data.jwt"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This next example shows doing the same token signature verification, decoding, and content checks
but instead with a single call to `io.jwt.decode_verify`. Note that this gives less flexibility
in validating the payload content as **all** claims defined in the JWT spec are verified with the
provided constraints.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Certificate Verify Single
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"showPlayground": false,
"command": "data.jwt"
"showInput": false,
"showData": false,
"showTitles": false,
"showPlayground": false,
"titleSize": 5,
"command": "data.jwt"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
This example shows a two-step process to verify the token signature and then decode it for
further checks of the payload content. This approach gives more flexibility in verifying only
the claims that the policy needs to enforce.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
JWKS Verify
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"showPlayground": false,
"command": "data.jwt"
"showInput": false,
"showData": false,
"showTitles": false,
"showPlayground": false,
"titleSize": 5,
"command": "data.jwt"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
This next example shows doing the token signature verification, decoding, and content checks
all in one call using `io.jwt.decode_verify`. Note that this gives less flexibility in validating
the payload content as **all** claims defined in the JWT spec are verified with the provided
constraints.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
JWKS Single Verify
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"command": "data.jwt"
"showInput": false,
"showData": false,
"showTitles": false,
"titleSize": 5,
"command": "data.jwt"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This one demonstrates how to encode the and sign the same token contents as in the example above but with `io.jwt.encode_sign` instead of the `raw` variant.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sign and Verify
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"showInput": false,
"showData": false,
"showTitles": false,
"command": "data.jwt"
"showInput": false,
"showData": false,
"showTitles": false,
"titleSize": 5,
"command": "data.jwt"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
This exambles demonstrates how to do this using the `io.jwt.encode_sign_raw` built-in:
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Sign and Verify Raw
Loading
Loading