Skip to content

Commit 9297e2e

Browse files
committed
Wire in baton ID into server grants
1 parent f311f67 commit 9297e2e

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

pkg/connector/server.go

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,17 +131,22 @@ func (d *serverSyncer) Grants(ctx context.Context, resource *v2.Resource, pToken
131131
if err != nil {
132132
return nil, "", nil, err
133133
}
134+
135+
principal := &v2.ResourceId{
136+
ResourceType: rt.Id,
137+
Resource: strconv.FormatInt(p.PrincipalID, 10),
138+
}
139+
140+
grantOpts, err := BuildBatonIDGrantOptions(principal, p.PrincipalType, p.PrincipalName)
141+
if err != nil {
142+
return nil, "", nil, err
143+
}
144+
134145
switch p.State {
135146
case "G":
136-
ret = append(ret, grTypes.NewGrant(resource, perm, &v2.ResourceId{
137-
ResourceType: rt.Id,
138-
Resource: strconv.FormatInt(p.PrincipalID, 10),
139-
}))
147+
ret = append(ret, grTypes.NewGrant(resource, perm, principal, grantOpts...))
140148
case "W":
141-
ret = append(ret, grTypes.NewGrant(resource, perm+"-grant", &v2.ResourceId{
142-
ResourceType: rt.Id,
143-
Resource: strconv.FormatInt(p.PrincipalID, 10),
144-
}))
149+
ret = append(ret, grTypes.NewGrant(resource, perm+"-grant", principal, grantOpts...))
145150
}
146151
}
147152
}

0 commit comments

Comments
 (0)