security:authorization:openfga:authorization-model:keyword-vs-name
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| security:authorization:openfga:authorization-model:keyword-vs-name [2026/07/09 04:15] – [See also] phong2018 | security:authorization:openfga:authorization-model:keyword-vs-name [2026/07/09 04:36] (current) – phong2018 | ||
|---|---|---|---|
| Line 67: | Line 67: | ||
| DEFINE <your relation name>: [< | DEFINE <your relation name>: [< | ||
| </ | </ | ||
| + | |||
| + | ===== The keywords as concepts ===== | ||
| + | |||
| + | Each keyword plays one clear role. Think of building the model top to bottom: | ||
| + | first the file, then a type, then its relations, then each rule. | ||
| + | |||
| + | ==== model ==== | ||
| + | |||
| + | **Concept: | ||
| + | |||
| + | You write it once, at the very top. Nothing lives outside it. | ||
| + | |||
| + | < | ||
| + | model | ||
| + | schema 1.1 | ||
| + | </ | ||
| + | |||
| + | ==== schema ==== | ||
| + | |||
| + | **Concept: | ||
| + | |||
| + | Always pair it with a version, like '' | ||
| + | |||
| + | < | ||
| + | schema 1.1 | ||
| + | </ | ||
| + | |||
| + | ==== type ==== | ||
| + | |||
| + | **Concept: | ||
| + | |||
| + | A type is a category of object, like a user, a document, or a folder. You will | ||
| + | have one '' | ||
| + | choose. | ||
| + | |||
| + | < | ||
| + | type document | ||
| + | </ | ||
| + | |||
| + | Read it as: **" | ||
| + | |||
| + | ==== relations ==== | ||
| + | |||
| + | **Concept: | ||
| + | |||
| + | It has no rule of its own. It just says "the rules for this type start here." | ||
| + | Everything indented under it belongs to that type. | ||
| + | |||
| + | < | ||
| + | type document | ||
| + | relations | ||
| + | define owner: [user] | ||
| + | define viewer: [user] or owner | ||
| + | </ | ||
| + | |||
| + | Read it as: **" | ||
| + | |||
| + | ==== define ==== | ||
| + | |||
| + | **Concept: | ||
| + | |||
| + | Each '' | ||
| + | many '' | ||
| + | |||
| + | < | ||
| + | define owner: [user] | ||
| + | </ | ||
| + | |||
| + | Read it as: **" | ||
| + | |||
| + | ==== or / and / but not ==== | ||
| + | |||
| + | **Concept: | ||
| + | |||
| + | * '' | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | < | ||
| + | define editor: [user] or owner | ||
| + | define can_delete: owner and admin | ||
| + | define viewer: [user] but not blocked | ||
| + | </ | ||
| + | |||
| + | ==== from ==== | ||
| + | |||
| + | **Concept: | ||
| + | |||
| + | It lets access flow between objects. You name a link to follow, then a relation | ||
| + | to check on the other side. | ||
| + | |||
| + | < | ||
| + | define viewer: viewer from parent | ||
| + | </ | ||
| + | |||
| + | Read it as: **"you are a viewer here if you are a viewer of the // | ||
| + | |||
| + | ===== How they nest ===== | ||
| + | |||
| + | The keywords stack inside each other, shown by indentation: | ||
| + | |||
| + | < | ||
| + | model ← the whole file | ||
| + | schema 1.1 ← the DSL version | ||
| + | | ||
| + | type document | ||
| + | relations | ||
| + | define owner: [user] | ||
| + | define editor: [user] or owner ← one rule, using " | ||
| + | </ | ||
| + | |||
| + | <note tip> | ||
| + | Reading order: '' | ||
| + | Outer keywords set the container; inner ones fill in the detail. | ||
| + | </ | ||
| + | |||
| + | ===== More examples to read ===== | ||
| + | |||
| + | The trick to reading a relation is to say it out loud in plain words. Below, the | ||
| + | left side is the DSL, the right side is how you say it. | ||
| + | |||
| + | ==== Direct grant ==== | ||
| + | |||
| + | < | ||
| + | define owner: [user] | ||
| + | </ | ||
| + | |||
| + | Read it as: **"a user can be assigned as the owner." | ||
| + | Keyword: '' | ||
| + | |||
| + | ==== Union with '' | ||
| + | |||
| + | < | ||
| + | define editor: [user] or owner | ||
| + | </ | ||
| + | |||
| + | Read it as: **"an editor is a user assigned directly, //or// anyone who is already | ||
| + | an owner." | ||
| + | So every owner is also an editor, for free. | ||
| + | |||
| + | ==== More than one allowed type ==== | ||
| + | |||
| + | < | ||
| + | define member: [user, group# | ||
| + | </ | ||
| + | |||
| + | Read it as: **"a member can be a single user, //or// every member of a group." | ||
| + | The comma lists two allowed types. '' | ||
| + | |||
| + | ==== Public access with a wildcard ==== | ||
| + | |||
| + | < | ||
| + | define viewer: [user:*] | ||
| + | </ | ||
| + | |||
| + | Read it as: **" | ||
| + | The '' | ||
| + | |||
| + | ==== Both must be true with '' | ||
| + | |||
| + | < | ||
| + | define can_delete: owner and admin | ||
| + | </ | ||
| + | |||
| + | Read it as: **"you can delete only if you are //both// an owner //and// an admin." | ||
| + | '' | ||
| + | |||
| + | ==== Take away with '' | ||
| + | |||
| + | < | ||
| + | define viewer: [user] but not blocked | ||
| + | </ | ||
| + | |||
| + | Read it as: **"a viewer is any assigned user, //except// anyone who is blocked." | ||
| + | '' | ||
| + | |||
| + | ==== Inherit through a link with '' | ||
| + | |||
| + | < | ||
| + | define viewer: viewer from parent | ||
| + | </ | ||
| + | |||
| + | Read it as: **"you can view this if you are a viewer of its parent." | ||
| + | Follow the '' | ||
| + | |||
| + | ==== Everything combined ==== | ||
| + | |||
| + | < | ||
| + | define viewer: [user] or editor or viewer from parent | ||
| + | </ | ||
| + | |||
| + | Read it as: **"a viewer is a user assigned directly, //or// an editor, //or// a | ||
| + | viewer of the parent folder." | ||
| + | This is the common real-world pattern: direct people, higher roles, and inherited | ||
| + | folder access all at once. | ||
| + | |||
| + | ===== Quick reading table ===== | ||
| + | |||
| + | ^ DSL ^ Read it as ^ | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | | '' | ||
| + | |||
| + | <note tip> | ||
| + | Rule of thumb: '' | ||
| + | name means a // | ||
| + | </ | ||
| ===== See also ===== | ===== See also ===== | ||
| Line 72: | Line 283: | ||
| * [[security: | * [[security: | ||
| * [[security: | * [[security: | ||
| - | * [[https:// | + | |
security/authorization/openfga/authorization-model/keyword-vs-name.1783570527.txt.gz · Last modified: by phong2018
