Karl Azzam
01/11/2024, 12:34 AMDennis (Cerbos)
Karl Azzam
01/11/2024, 1:09 AMKarl Azzam
01/11/2024, 1:11 AMDennis (Cerbos)
Dennis (Cerbos)
Karl Azzam
01/11/2024, 1:40 AMDennis (Cerbos)
CheckResult result=client.check(
Principal.newInstance("john","employee")
.withPolicyVersion("20210210")
.withAttribute("department",stringValue("marketing"))
.withAttribute("geography",stringValue("GB")),
Resource.newInstance("leave_request","xx125")
.withPolicyVersion("20210210")
.withAttribute("department",stringValue("marketing"))
.withAttribute("geography",stringValue("GB"))
.withAttribute("owner",stringValue("john")),
"view:public","approve");
if(result.isAllowed("approve")){ // returns true if `approve` action is allowed
...
}
You need to use the withAttribute
method to add a resource attribute with the path parameter value. How you read it depends on your web framework.Karl Azzam
01/11/2024, 1:52 AMKarl Azzam
01/11/2024, 1:52 AMKarl Azzam
01/11/2024, 1:53 AMKarl Azzam
01/11/2024, 1:55 AMDennis (Cerbos)
Karl Azzam
01/11/2024, 2:01 AMKarl Azzam
01/11/2024, 2:01 AMDennis (Cerbos)
Karl Azzam
01/11/2024, 2:01 AM