Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: add example for meeting to write policy #57

Closed
wants to merge 2 commits into from
Closed
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
54 changes: 54 additions & 0 deletions policyexamples/example1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Example

Policy example where the user name is encoded in base64 authentication (Basic http token)

- Here user alice is granted a guest role and can perform a GET request to /productpage.
- And user bob is granted an admin role and can perform a GET to /productpage and /api/v1/products.

```
base64_decode(YWxpY2U6cGFzc3dvcmQ=) = alice:password
base64_decode(Ym9iOnBhc3N3b3Jk) = bob:password
```


Below is the example of good request payload which should pass the policy
```json
{
"attributes": {
"request": {
"http": {
"method": "GET",
"path": "/productpage",
"headers": {
"authorization": "Basic YWxpY2U6cGFzc3dvcmQ="
}
}
}
}
}
```

Below is the example of bad request payload which should fail the policy
Here alice is trying to make `GET` request on path `api/v1/products` which is not allowed.
```json
{
"attributes": {
"request": {
"http": {
"method": "GET",
"path": "/api/v1/products",
"headers": {
"authorization": "Basic YWxpY2U6cGFzc3dvcmQ="
}
}
}
}
}
```

Below is the example of validation policy that restricts access to an endpoint based on a user’s role and permissions.
```yml
....

....
```