2023-03-28 18:39:22 +00:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-08-11 13:12:13 +00:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-28 18:39:22 +00:00
|
|
|
|
2022-06-15 19:36:18 +00:00
|
|
|
package connect
|
|
|
|
|
|
|
|
import (
|
|
|
|
"net/url"
|
|
|
|
|
|
|
|
"github.com/hashicorp/consul/acl"
|
|
|
|
)
|
|
|
|
|
|
|
|
type SpiffeIDMeshGateway struct {
|
|
|
|
Host string
|
|
|
|
Partition string
|
|
|
|
Datacenter string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (id SpiffeIDMeshGateway) MatchesPartition(partition string) bool {
|
|
|
|
return id.PartitionOrDefault() == acl.PartitionOrDefault(partition)
|
|
|
|
}
|
|
|
|
|
|
|
|
func (id SpiffeIDMeshGateway) PartitionOrDefault() string {
|
|
|
|
return acl.PartitionOrDefault(id.Partition)
|
|
|
|
}
|
|
|
|
|
|
|
|
// URI returns the *url.URL for this SPIFFE ID.
|
|
|
|
func (id SpiffeIDMeshGateway) URI() *url.URL {
|
|
|
|
var result url.URL
|
|
|
|
result.Scheme = "spiffe"
|
|
|
|
result.Host = id.Host
|
|
|
|
result.Path = id.uriPath()
|
|
|
|
return &result
|
|
|
|
}
|