Skip to content

Commit

Permalink
feat(oathkeeper): add api notes rules
Browse files Browse the repository at this point in the history
Signed-off-by: iverly <github@iverly.net>
  • Loading branch information
iverly committed Nov 27, 2023
1 parent d240439 commit 0560f15
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 0 deletions.
1 change: 1 addition & 0 deletions config/oathkeeper/oathkeeper.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ access_rules:
- file:///etc/config/oathkeeper/rules/auth.yaml
- file:///etc/config/oathkeeper/rules/kratos.yaml
- file:///etc/config/oathkeeper/rules/dev.yaml
- file:///etc/config/oathkeeper/rules/api-notes.yaml

authenticators:
anonymous:
Expand Down
63 changes: 63 additions & 0 deletions config/oathkeeper/rules/api-notes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#######################################
# Notes Access Rules #
#######################################
- id: "api:create-note:protected"
upstream:
preserve_host: true
url: "http://api:3100"
match:
url: http://api.nx-next-nest-prisma-ory-template.<127\.0\.0\.1\.sslip\.io|com>/notes
methods:
- POST
authenticators:
- handler: cookie_session
authorizer:
handler: allow
mutators:
- handler: id_token
errors:
- handler: redirect

- id: "api:note:protected"
upstream:
preserve_host: true
url: "http://api:3100"
match:
url: http://api.nx-next-nest-prisma-ory-template.<127\.0\.0\.1\.sslip\.io|com>/notes/<([0-9a-f]{8}-[0-9a-f]{4}-4[0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})>
methods:
- GET
- PATCH
- DELETE
authenticators:
- handler: cookie_session
authorizer:
handler: remote_json
config:
payload: |
{
"namespace": "notes",
"object": "{{ printIndex .MatchContext.RegexpCaptureGroups 1 }}",
"relation": "owner",
"subject_id": "{{ print .Subject }}"
}
mutators:
- handler: id_token
errors:
- handler: redirect

- id: "api:list-note:protected"
upstream:
preserve_host: true
url: "http://api:3100"
match:
url: http://api.nx-next-nest-prisma-ory-template.<127\.0\.0\.1\.sslip\.io|com>/notes
methods:
- GET
authenticators:
- handler: cookie_session
authorizer:
handler: allow
mutators:
- handler: id_token
errors:
- handler: redirect
1 change: 1 addition & 0 deletions docker-compose.base.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ services:
- ./config/oathkeeper/id_token.jwks.json:/etc/config/oathkeeper/id_token.jwks.json
- ./config/oathkeeper/rules/auth.yaml:/etc/config/oathkeeper/rules/auth.yaml
- ./config/oathkeeper/rules/kratos.yaml:/etc/config/oathkeeper/rules/kratos.yaml
- ./config/oathkeeper/rules/api-notes.yaml:/etc/config/oathkeeper/rules/api-notes.yaml
depends_on:
- kratos

Expand Down

0 comments on commit 0560f15

Please sign in to comment.