Skip to content

Commit

Permalink
PR(MAIN): Add ability revoke from all actors (if shared with *)
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzadlone committed Nov 21, 2024
1 parent d2a8cfe commit e35b591
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
18 changes: 17 additions & 1 deletion acp/acp_local.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,9 +301,25 @@ func (l *ACPLocal) DeleteActorRelationship(

ctx = auth.InjectPrincipal(ctx, principal)

var newActorRelationship *types.Relationship
if targetActor == "*" {
newActorRelationship = types.NewAllActorsRelationship(
resourceName,
objectID,
relation,
)
} else {
newActorRelationship = types.NewActorRelationship(
resourceName,
objectID,
relation,
targetActor,
)
}

deleteRelationshipRequest := types.DeleteRelationshipRequest{
PolicyId: policyID,
Relationship: types.NewActorRelationship(resourceName, objectID, relation, targetActor),
Relationship: newActorRelationship,
}

deleteRelationshipResponse, err := l.engine.DeleteRelationship(ctx, &deleteRelationshipRequest)
Expand Down
32 changes: 21 additions & 11 deletions acp/acp_source_hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,18 +333,28 @@ func (a *acpSourceHub) DeleteActorRelationship(
creationTime *protoTypes.Timestamp,
) (bool, error) {
msgSet := sourcehub.MsgSet{}

var newActorRelationship *acptypes.Relationship
if targetActor == "*" {
newActorRelationship = acptypes.NewAllActorsRelationship(
resourceName,
objectID,
relation,
)
} else {
newActorRelationship = acptypes.NewActorRelationship(
resourceName,
objectID,
relation,
targetActor,
)
}

cmdMapper := msgSet.WithBearerPolicyCmd(&acptypes.MsgBearerPolicyCmd{
Creator: a.signer.GetAccAddress(),
BearerToken: requester.BearerToken,
PolicyId: policyID,
Cmd: acptypes.NewDeleteRelationshipCmd(
acptypes.NewActorRelationship(
resourceName,
objectID,
relation,
targetActor,
),
),
Creator: a.signer.GetAccAddress(),
BearerToken: requester.BearerToken,
PolicyId: policyID,
Cmd: acptypes.NewDeleteRelationshipCmd(newActorRelationship),
CreationTime: creationTime,
})

Expand Down

0 comments on commit e35b591

Please sign in to comment.