Request for separate Channel object type in spiceDB #2289
Replies: 1 comment
-
There is a pre check condition in spiceDB for adding policy for group with parent group, This pre check condition check for parent ID is present in same domain to which group is present. This precondition check helps to solve partially the Case 1 . Then While adding group with channel ID's UUID as parent , It will fails in pre condition check, since channel ID's UUID will be member of domain, |
Beta Was this translation helpful? Give feedback.
-
Case 1
Both Group and Channels share the same implementation
pkg/groups/groups.go
,internal/groups/service.go
and same data structure in database.Groups are present in
users
service. Their tables are present inusers db
When you try to create group with parent as channel, It wont happens, it get fails.
Example :
User service logs
Logs from users service database
It fails due to Foreign key reference in groups table, which requires
parent_id
that need to present in same table.Here the
channel_id
is not present in same table ,they are present in table in database to whichthings
service is connected .On any entity creation, there will two major action take place, Adding policy to spice db and adding entity to database
First the adding of policy take place , then followed by adding of entity to database.
So here in this case, If we the policy is added to spicedb, then it is remove , because if entity is failed to add to database ,the service will rollback the policy,
Suggestion:
We should detect before adding to repo, during policy addition we should have this check.
So that we can avoid adding and rollback of policy.
To do this like of check in policy, we need some kind distinguish between channels and groups in spicedb
The one of way i see is by having different object type for channels and groups
Case 2
Things could not be related to groups as subscribe or publish relation , Instead group related to thing as publish or subscribe relation.
In present case , thing is object and group becomes subject.
If we have publish and subscribe relation, then it would be like
Group
(Subject)
havepublish
relation
withThing
(object)
Group
(Subject)
havesubscribe
relation withThing
(object)
Because of this we could not check
thing
havepub/sub
permission
ongroup(channel)
Instead we check like following :
Does
Group
havepublish
permission
tothing
Does
Group
havesubscribe
permission
tothing
?This concept will work, it is one of the practical way of implementation, but it doesn't match with theoretical architecture of MG
In theoretical architecture, channels are communication conduit, to which thing are connect.
So according to this theory, permission check should be like:
Does the
thing
havepub/sub
permission
ongroup(channel)
If we want to have the same the theoretical architecture in MG
Then we need to change thing to subject and group to object.
Relation will be like
Thing``(subject)
havepublish
relation withGroup``(object)
Thing
(subject)have
subscriberelation with
Group``(object)`Then we can have permission check will be like
Does
Thing
havepublish
permission
toGroup
Does
Thing
havesubscribe
permission
toGroup
?To have this change we need to separate group and channels in spicedb
Because Group and channel share the type in spicedb , Type name is
Group
Group/Channel
can havegroup
(like connect) relation withthing
objectExisting:
if we didn't separate the group and channels and tries to implement,
then Group want to be object, then
thing
should havepub/sub
relation withGroup/Channel
This leads to
thing
havingpub/sub
relation touser group
, since we could not distinguish between channels and groups in spicedbSo If we have separate object type channel, the have dedicated pub/sub relation for thing to channel.
This will avoid the thing having pub/sub relation with groups
Beta Was this translation helpful? Give feedback.
All reactions