Skip to content
Discussion options

You must be logged in to vote

Hi @pccrazy 👋

That would depend on how your API is structured, but as an example — if the input were to look something like this:

{
    "request": {
        "method": "PUT",
        "path": [
            "users",
            "abc123",
            "password"
        ]
    },
    "user": {
        "id": "abc123",
        "roles": [
            "client"
        ]
    }
}

A policy to allow updates of the users' password resource could look something like this:

package play

import future.keywords.if
import future.keywords.in

default allow := false

allow if {
	input.request.method == "PUT"
	input.request.path == ["users", input.user.id, "password"]
	"client" in input.user.roles
}

Full exampl…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@anwar-al-jahwari
Comment options

Answer selected by anwar-al-jahwari
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants