takenpilot
11/10/2023, 12:39 PMvroldanbet
11/10/2023, 1:28 PMvroldanbet
11/10/2023, 1:30 PMdefinition starship {
relation commander: user
permission view = commander
}
definition system {
relation starship: starship
permission view = starship->view
}
takenpilot
11/10/2023, 1:33 PMyetitwo
11/10/2023, 1:43 PMyetitwo
11/10/2023, 1:43 PMyetitwo
11/10/2023, 1:44 PMyetitwo
11/10/2023, 1:44 PMyetitwo
11/10/2023, 1:44 PMLee Trout
11/10/2023, 1:55 PMyetitwo
11/10/2023, 1:56 PMyetitwo
11/10/2023, 1:56 PMyetitwo
11/10/2023, 1:57 PMLee Trout
11/10/2023, 1:59 PMvroldanbet
11/10/2023, 2:00 PMyetitwo
11/10/2023, 2:00 PMvroldanbet
11/10/2023, 2:02 PMLee Trout
11/10/2023, 2:02 PMvroldanbet
11/10/2023, 2:02 PMvroldanbet
11/10/2023, 2:03 PMLee Trout
11/10/2023, 2:03 PMvroldanbet
11/10/2023, 2:04 PMyetitwo
11/10/2023, 2:06 PMtakenpilot
11/10/2023, 2:06 PMvroldanbet
11/10/2023, 2:07 PMvroldanbet
11/10/2023, 2:09 PMtakenpilot
11/10/2023, 2:13 PMyetitwo
11/10/2023, 2:21 PMyetitwo
11/10/2023, 2:22 PMrole_binding
is the thing that connects the user ("who") to the entity ("what") and the role ("how")yetitwo
11/10/2023, 2:22 PMrole_binding
can technically be connected to any number of roles, users, and entitiesyetitwo
11/10/2023, 2:23 PMtakenpilot
11/10/2023, 2:29 PMtakenpilot
11/10/2023, 2:31 PMtakenpilot
11/10/2023, 2:44 PMyetitwo
11/10/2023, 3:11 PMyetitwo
11/10/2023, 3:12 PMyetitwo
11/10/2023, 3:12 PMtakenpilot
11/10/2023, 3:13 PMtakenpilot
11/10/2023, 3:21 PMtakenpilot
11/10/2023, 3:21 PMyetitwo
11/10/2023, 3:30 PMyetitwo
11/10/2023, 3:30 PMtakenpilot
11/10/2023, 3:38 PMyetitwo
11/10/2023, 4:09 PMyetitwo
11/10/2023, 4:10 PMyetitwo
11/10/2023, 4:10 PMtakenpilot
11/10/2023, 4:14 PMtakenpilot
11/11/2023, 2:32 PMschema: >-
definition user {}
definition starship {
relation crew_member: user
}
definition starship_role {
relation starship: starship
relation user: user
}
definition starship_system {
relation starship: starship
relation role: starship_role#user
permission operate = starship->crew_member & role
}
relationships: >-
starship_role:captain#starship@starship:enterprise
starship_role:captain#user@user:picard
starship_role:starfleet#user@user:picard
starship_role:captain#user@user:kirk
starship_role:starfleet#user@user:kirk
starship_role:starfleet#user@user:wesley
starship:enterprise#crew_member@user:picard
starship:enterprise#crew_member@user:wesley
starship_system:enterprise_bridge#starship@starship:enterprise
starship_system:enterprise_bridge#role@starship_role:captain#user
starship_system:sickbay#starship@starship:enterprise
starship_system:sickbay#role@starship_role:starfleet#user
assertions:
assertTrue:
- "starship_role:captain#user@user:picard"
- "starship_system:enterprise_bridge#operate@user:picard"
- "starship_system:sickbay#operate@user:picard"
- "starship:enterprise#crew_member@user:wesley"
- "starship_system:sickbay#operate@user:wesley"
assertFalse:
- "starship_system:enterprise_bridge#operate@user:kirk"
- "starship_system:sickbay#operate@user:kirk"
- "starship_system:enterprise_bridge#operate@user:wesley"
That is, both Kirk and Picard are captains. Wesley and Picard are crew members on the ship currently. Picard and Wesley are allowed in the sickbay. Wesley is NOT allowed on the bridge.
Following this pattern, we can define different systems on different ships, and the systems determine which roles are allowed to operate them while also only allowing those that are associated with their particular ship.
(edited a few times to make the example simpler.)takenpilot
11/11/2023, 2:34 PMtakenpilot
11/11/2023, 2:36 PMtakenpilot
11/11/2023, 2:37 PMAlec
11/11/2023, 3:23 PMAlec
11/11/2023, 3:24 PMtakenpilot
11/11/2023, 3:38 PMtakenpilot
11/11/2023, 3:39 PMtakenpilot
11/11/2023, 3:40 PMtakenpilot
11/11/2023, 3:41 PMtakenpilot
11/11/2023, 3:46 PMrelation starship: starship
in the starship_role
. It's unnecessary. 🤔yetitwo
11/11/2023, 4:00 PMyetitwo
11/11/2023, 4:01 PMyetitwo
11/11/2023, 4:01 PMyetitwo
11/11/2023, 4:01 PMtakenpilot
11/11/2023, 4:06 PMyetitwo
11/11/2023, 5:01 PMyetitwo
11/11/2023, 5:01 PMyetitwo
11/11/2023, 5:02 PMyetitwo
11/11/2023, 5:02 PMyetitwo
11/11/2023, 5:03 PMWriteRelationships
request that removes the use_intercom
permission from the captain's role, which can happen at runtime, without needing to modify codeyetitwo
11/11/2023, 5:04 PMtakenpilot
11/11/2023, 10:59 PMtakenpilot
11/11/2023, 11:10 PMyetitwo
11/11/2023, 11:20 PMyetitwo
11/11/2023, 11:21 PMcomms_operator
and bridge_operator
defined separatelyyetitwo
11/11/2023, 11:21 PMyetitwo
11/11/2023, 11:21 PMtakenpilot
11/11/2023, 11:36 PMstarship_role:captain#user@user:picard
starship_system:enterprise_bridge#role@starship_role:captain#user
yetitwo
11/11/2023, 11:43 PMstarship_role
is your name for the role_binding
definition in the custom role schema?takenpilot
11/11/2023, 11:48 PMuser:*
, which is then used in a kind of any/never set math to do logic, and then intersected that with the actual list of users who should have access.takenpilot
11/11/2023, 11:50 PM#
operator in a relationship, which is weird and I didn't see examples of it in the blogs, only references in psuedocode, but it works.yetitwo
11/12/2023, 1:41 AM#
is called iirc)yetitwo
11/12/2023, 1:41 AMAlec
11/12/2023, 2:32 AMtakenpilot
11/12/2023, 4:02 AMtakenpilot
11/12/2023, 4:04 AMtakenpilot
11/12/2023, 4:05 AMtakenpilot
11/12/2023, 4:06 AMtakenpilot
11/12/2023, 4:09 AM