fix(handler): return targetId as hostId for cli edge case support (#2920)
This commit is contained in:
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(),
|
||||
|
||||
@@ -28,6 +28,7 @@ const (
|
||||
MultiHopSessionFeature
|
||||
IncludeStatusInCli
|
||||
CredentialLibraryVaultSubtype
|
||||
UseTargetIdForHostId
|
||||
)
|
||||
|
||||
var featureMap map[Feature]MetadataConstraint
|
||||
@@ -65,6 +66,15 @@ func init() {
|
||||
MetaInfo: []Metadata{OSS, HCP},
|
||||
Constraints: mustNewConstraints("< 0.14.0"),
|
||||
}
|
||||
|
||||
// UseTargetIdForHostId supports old CLI clients that are unaware of host-sourceless targets,
|
||||
// this feature populates the target's public id into the AuthorizeSessionResponse
|
||||
// and the SessionAuthroizationData so the CLI can properly build the ssh command
|
||||
// when calling "boundary connect ssh..."
|
||||
featureMap[UseTargetIdForHostId] = MetadataConstraint{
|
||||
MetaInfo: []Metadata{OSS, HCP},
|
||||
Constraints: mustNewConstraints("< 0.14.0"),
|
||||
}
|
||||
}
|
||||
|
||||
func metadataStringToMetadata(m string) Metadata {
|
||||
|
||||
Reference in new issue
Block a user