fix(handler): return targetId as hostId for cli edge case support (#2920)

This commit is contained in:
Damian Debkowski authored and GitHub committed 2023-02-07 10:14:01 -08:00
1 parent f88547bbf5
commit cabe362534
2 files changed
+18

No files matched your search

@@ -40,6 +40,7 @@ import (
"github.com/hashicorp/boundary/internal/types/subtypes"
"github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/scopes"
pb "github.com/hashicorp/boundary/sdk/pbs/controller/api/resources/targets"
fm "github.com/hashicorp/boundary/version"
"github.com/hashicorp/go-bexpr"
"github.com/hashicorp/go-secure-stdlib/strutil"
"github.com/mr-tron/base58"
@@ -984,6 +985,13 @@ func (s Service) AuthorizeSession(ctx context.Context, req *pbs.AuthorizeSession
}
}
// this is an edge case issue where the hostId cannot be empty when trying to execute an ssh connection
// on a tcp target type. By setting the hostId to the targetId value, this will enable support of previous
// boundary cli versions.
if fm.SupportsFeature(fm.Binary, fm.UseTargetIdForHostId) && t.GetAddress() != "" {
hostId = t.GetPublicId()
}
sad := &pb.SessionAuthorizationData{
SessionId: sess.PublicId,
TargetId: t.GetPublicId(),