Rinat Sharipov
06/13/2024, 1:14 PMdefinition smile2impress/employee {
}
definition smile2impress/organization {
// appoitments management
relation appointment_creator: smile2impress/role#member
relation blacklisted_on_appointment_creation: smile2impress/employee
relation allowed_appointment_types_to_create_appointment: smile2impress/employee with allowed_appointment_type
permission create_appointment = (appointment_creator - blacklisted_on_appointment_creation) + allowed_appointment_types_to_create_appointment
}
caveat allowed_appointment_type(appointment_type string, allowed_appointment_types list<string>) {
appointment_type in allowed_appointment_types
}
as you see, I'm adding relation with the same employee twice, once to blacklist and block his access by role, second to allow access for a specific kind of appointments
from my point of view, the ideal situation should be schema where I can do ignore caveat during removal employee from allowed by role and grant access by caveat rule
in such case I need to keep only one extra relation
permission create_appointment = (appointment_creator - blacklisted_on_appointment_creation#employee) + blacklisted_on_appointment_creation
vroldanbet
06/13/2024, 1:27 PMRinat Sharipov
06/13/2024, 1:30 PMRinat Sharipov
06/13/2024, 1:32 PMvroldanbet
06/13/2024, 1:36 PMvroldanbet
06/13/2024, 1:37 PMvroldanbet
06/13/2024, 1:37 PMvroldanbet
06/13/2024, 1:37 PMRinat Sharipov
06/13/2024, 1:43 PMRinat Sharipov
06/13/2024, 2:06 PMvroldanbet
06/13/2024, 2:19 PMdefinition smile2impress/employee {
}
definition smile2impress/organization {
// appoitments management
relation appointment_creator: smile2impress/role#member
relation allowed_only_on_specific_types: smile2impress/employee with allowed_appointment_type
permission create_appointment = appointment_creator + allowed_only_on_specific_types
}
caveat allowed_appointment_type(appointment_type string, allowed_appointment_types list<string>) {
appointment_type in allowed_appointment_types
}
vroldanbet
06/13/2024, 2:19 PMRinat Sharipov
06/13/2024, 2:25 PMRinat Sharipov
06/13/2024, 2:27 PMsmile2impress/role:admin#member@smile2impress/employee:rinat
smile2impress/role:doctor#member@smile2impress/employee:georgy
smile2impress/application:kdk#user@smile2impress/role:admin#member
smile2impress/application:kdk#user@smile2impress/role:doctor#member
smile2impress/organization:impress#appointment_creator@smile2impress/role:admin#member
smile2impress/organization:impress#appointment_creator@smile2impress/role:doctor#member
smile2impress/organization:impress#allowed_only_on_specific_types@smile2impress/employee:rinat[allowed_appointment_type:{"allowed_appointment_types":["first_visit"]}]
assertTrue:
- smile2impress/application:kdk#use@smile2impress/employee:rinat
- smile2impress/application:kdk#use@smile2impress/employee:georgy
- 'smile2impress/organization:impress#create_appointment@smile2impress/employee:rinat with {"appointment_type": "first_visit"}'
assertFalse:
- smile2impress/application:patienthub#use@smile2impress/employee:rinat
- 'smile2impress/organization:impress#create_appointment@smile2impress/employee:rinat with {"appointment_type": "second_visit"}'
this condition should fail, but it don't
- 'smile2impress/organization:impress#create_appointment@smile2impress/employee:rinat with {"appointment_type": "second_visit"}'
vroldanbet
06/13/2024, 5:09 PMRinat Sharipov
06/13/2024, 6:04 PMvroldanbet
06/14/2024, 9:23 AMzed terminal
tab, and run a check with explain:
https://cdn.discordapp.com/attachments/1250800471342317588/1251104594470371398/image.png?ex=666d5d73&is=666c0bf3&hm=8494ec72df62f27775b5311ac2002520eb6e39e24275948c1f1c591c515cf64f&