Skip to content

Commit 51f4fdc

Browse files
committed
fix: use ids instead of id
1 parent 95196e8 commit 51f4fdc

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

internal/boundary/boundary_test.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,3 +200,14 @@ func TestSSHHostKeyAlias(t *testing.T) {
200200
})
201201
}
202202
}
203+
204+
func TestAuthorizeSessionGrant(t *testing.T) {
205+
t.Parallel()
206+
207+
const targetID = "ttcp_pasAlBrMWb"
208+
want := "ids=ttcp_pasAlBrMWb;actions=authorize-session"
209+
210+
if got := authorizeSessionGrant(targetID); got != want {
211+
t.Fatalf("authorizeSessionGrant(%q) = %q, want %q", targetID, got, want)
212+
}
213+
}

internal/boundary/client.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ func (c *Client) AddGrantToRole(ctx context.Context, roleID string, targetID str
559559
return err
560560
}
561561

562-
grant := fmt.Sprintf("id=%s;actions=authorize-session", targetID)
562+
grant := authorizeSessionGrant(targetID)
563563
_, err = apiroles.NewClient(apiClient).AddGrants(ctx, roleID, 0, []string{grant}, apiroles.WithAutomaticVersioning(true))
564564
if err != nil {
565565
return fmt.Errorf("add grant to role: %w", err)
@@ -568,6 +568,10 @@ func (c *Client) AddGrantToRole(ctx context.Context, roleID string, targetID str
568568
return nil
569569
}
570570

571+
func authorizeSessionGrant(targetID string) string {
572+
return fmt.Sprintf("ids=%s;actions=authorize-session", targetID)
573+
}
574+
571575
// AddPrincipalToRole adds a user or managed group principal to a role.
572576
func (c *Client) AddPrincipalToRole(ctx context.Context, roleID string, principalID string) error {
573577
if strings.TrimSpace(roleID) == "" {

0 commit comments

Comments
 (0)