Skip to content

Commit

Permalink
chore(README): add after with resource_permissions example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
sfinnman authored and sfinnman committed Feb 2, 2023
1 parent b05d7e4 commit 56780c6
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,42 @@ message YourMethodRequest {
};
```

```proto
package your.pkg;
import "einride/iam/v1/annotations.proto";
service YourService {
rpc YourMethod(YourMethodRequest) returns YourMethodResponse {
option (einride.iam.v1.method_authorization) = {
resource_permissions {
resource_permission {
resource: {
type: "example.com/Entity1"
}
permission: "namespace.entity1.method"
}
resource_permission {
resource: {
type: "example.com/Entity2"
}
permission: "namespace.entity2.method"
}
}
after: {
expression: "test_all(caller, response.entities)" // iamcel expression
description: "The caller must have method permission against all entities"
}
};
};
}
message YourMethodResponse {
// Elements in this list are either Entity1 or Entity2 references
repeated string entities = 1;
};
```

Expresssions in the `method_authorization` annotation use [cel-go](https://github.com/google/cel-go) with [iamcel](./iamcel) extensions. The `iamcel` extensions provide the following cel functions.

#### [`test(caller Caller, resource string) bool`](./iamcel/test.go)
Expand Down

0 comments on commit 56780c6

Please sign in to comment.