Skip to content

Instantly share code, notes, and snippets.

@adam-sandor
Created July 8, 2021 16:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adam-sandor/b976e39729f25c3ae82e14a74073949e to your computer and use it in GitHub Desktop.
Save adam-sandor/b976e39729f25c3ae82e14a74073949e to your computer and use it in GitHub Desktop.
Rego rule 3 - Only managers from the employee_managers list can create employees
employee_managers := {"janedoe@styra.com","alicesmith@styra.com","davidholme@styra.com"}
allow {
input.attributes.request.http.method == "POST"
input.parsed_path[0] = "employees"
jwt.valid
jwt.payload.Role == "manager"
jwt.payload.Group == input.parsed_body.userGroup
employee_managers[_] == jwt.payload.sub #is the subject in the employee_managers set?
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment