-
-
Save fatihky/04830529e4281fdef5d8b3adc13e8ab7 to your computer and use it in GitHub Desktop.
cerbos - campaign - authorization
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| apiVersion: "api.cerbos.dev/v1" | |
| derivedRoles: | |
| name: campaign_roles | |
| definitions: | |
| - name: campaign_owner | |
| parentRoles: ["user"] | |
| condition: | |
| match: | |
| expr: request.resource.attr.campaign.owner == request.principal.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| apiVersion: "api.cerbos.dev/v1" | |
| derivedRoles: | |
| name: common_roles | |
| definitions: | |
| - name: admin | |
| parentRoles: ['admin'] | |
| - name: owner | |
| parentRoles: ["user"] | |
| condition: | |
| match: | |
| expr: request.resource.attr.owner == request.principal.id |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "requestId": "0011", | |
| "includeMeta": true, | |
| "actions": ["create"], | |
| "resource": { | |
| "kind": "campaign_keyword:object", | |
| "instances": { | |
| "0": { | |
| "attr": { | |
| "id": "0", | |
| "campaign": { | |
| "owner": "alicia" | |
| } | |
| } | |
| } | |
| } | |
| }, | |
| "principal": { | |
| "id": "alicia", | |
| "roles": ["user"] | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| apiVersion: api.cerbos.dev/v1 | |
| resourcePolicy: | |
| version: "default" | |
| importDerivedRoles: | |
| - common_roles | |
| resource: "campaign:object" | |
| rules: | |
| - actions: ['create'] | |
| effect: EFFECT_ALLOW | |
| roles: | |
| - user | |
| # UPDATE Policies | |
| # Currently on the display names of the campaigns can be updated | |
| # by the admins or the owners of the campaigns. | |
| - actions: ['update:displayName'] | |
| effect: EFFECT_ALLOW | |
| derivedRoles: | |
| - owner |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| apiVersion: api.cerbos.dev/v1 | |
| resourcePolicy: | |
| version: "default" | |
| # When I omit `common_roles` below, the principal gets the `campaign_owner` | |
| # derived role successfully. Otherwise the user doesn't get any derived role. | |
| importDerivedRoles: | |
| - campaign_roles | |
| - common_roles | |
| resource: "campaign_keyword:object" | |
| rules: | |
| - actions: ["create"] | |
| effect: EFFECT_ALLOW | |
| derivedRoles: | |
| - campaign_owner | |
| - actions: ["delete"] | |
| effect: EFFECT_ALLOW | |
| derivedRoles: | |
| - campaign_owner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment