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
|
|
|
|
2021-11-16 18:04:01 +00:00
|
|
|
//go:build !consulent
|
2020-01-13 20:51:40 +00:00
|
|
|
// +build !consulent
|
|
|
|
|
|
|
|
package structs
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/consul/acl"
|
|
|
|
)
|
|
|
|
|
2022-03-13 03:55:53 +00:00
|
|
|
func (ixn *Intention) SourceEnterpriseMeta() *acl.EnterpriseMeta {
|
2021-07-22 18:20:45 +00:00
|
|
|
return DefaultEnterpriseMetaInDefaultPartition()
|
2020-08-27 17:20:58 +00:00
|
|
|
}
|
|
|
|
|
2022-03-13 03:55:53 +00:00
|
|
|
func (ixn *Intention) DestinationEnterpriseMeta() *acl.EnterpriseMeta {
|
2021-07-22 18:20:45 +00:00
|
|
|
return DefaultEnterpriseMetaInDefaultPartition()
|
2020-08-27 17:20:58 +00:00
|
|
|
}
|
|
|
|
|
2022-03-13 03:55:53 +00:00
|
|
|
func (e *IntentionMatchEntry) GetEnterpriseMeta() *acl.EnterpriseMeta {
|
2021-07-22 18:20:45 +00:00
|
|
|
return DefaultEnterpriseMetaInDefaultPartition()
|
2020-10-06 18:24:05 +00:00
|
|
|
}
|
|
|
|
|
2022-03-13 03:55:53 +00:00
|
|
|
func (e *IntentionQueryExact) SourceEnterpriseMeta() *acl.EnterpriseMeta {
|
2021-07-22 18:20:45 +00:00
|
|
|
return DefaultEnterpriseMetaInDefaultPartition()
|
2020-10-06 18:24:05 +00:00
|
|
|
}
|
|
|
|
|
2022-03-13 03:55:53 +00:00
|
|
|
func (e *IntentionQueryExact) DestinationEnterpriseMeta() *acl.EnterpriseMeta {
|
2021-07-22 18:20:45 +00:00
|
|
|
return DefaultEnterpriseMetaInDefaultPartition()
|
2020-10-06 18:24:05 +00:00
|
|
|
}
|
|
|
|
|
2020-01-13 20:51:40 +00:00
|
|
|
// FillAuthzContext can fill in an acl.AuthorizerContext object to setup
|
2023-08-22 14:46:03 +00:00
|
|
|
// extra parameters for ACL enforcement. In CE there is currently nothing
|
2020-01-13 20:51:40 +00:00
|
|
|
// extra to be done.
|
|
|
|
func (_ *Intention) FillAuthzContext(_ *acl.AuthorizerContext, _ bool) {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
// FillAuthzContext can fill in an acl.AuthorizerContext object to setup
|
2023-08-22 14:46:03 +00:00
|
|
|
// extra parameters for ACL enforcement. In CE there is currently nothing
|
2020-01-13 20:51:40 +00:00
|
|
|
// extra to be done.
|
|
|
|
func (_ *IntentionMatchEntry) FillAuthzContext(_ *acl.AuthorizerContext) {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
|
|
|
// FillAuthzContext can fill in an acl.AuthorizerContext object to setup
|
2023-08-22 14:46:03 +00:00
|
|
|
// extra parameters for ACL enforcement. In CE there is currently nothing
|
2020-01-13 20:51:40 +00:00
|
|
|
// extra to be done.
|
|
|
|
func (_ *IntentionQueryCheck) FillAuthzContext(_ *acl.AuthorizerContext) {
|
|
|
|
// do nothing
|
|
|
|
}
|
|
|
|
|
2021-09-08 15:59:30 +00:00
|
|
|
// FillPartitionAndNamespace will fill in empty source and destination partition/namespaces.
|
|
|
|
// If fillDefault is true, all fields are defaulted when the given enterprise meta does not
|
|
|
|
// specify them.
|
|
|
|
//
|
|
|
|
// fillDefault MUST be true on servers to ensure that all fields are populated on writes.
|
|
|
|
// fillDefault MUST be false on clients so that servers can correctly fill in the
|
|
|
|
// namespace/partition of the ACL token.
|
2022-03-13 03:55:53 +00:00
|
|
|
func (ixn *Intention) FillPartitionAndNamespace(entMeta *acl.EnterpriseMeta, fillDefault bool) {
|
2021-09-08 15:59:30 +00:00
|
|
|
if ixn == nil {
|
|
|
|
return
|
|
|
|
}
|
|
|
|
var ns = entMeta.NamespaceOrEmpty()
|
|
|
|
if fillDefault {
|
|
|
|
if ns == "" {
|
|
|
|
ns = IntentionDefaultNamespace
|
|
|
|
}
|
|
|
|
}
|
2020-01-13 20:51:40 +00:00
|
|
|
if ixn.SourceNS == "" {
|
2021-09-08 15:59:30 +00:00
|
|
|
ixn.SourceNS = ns
|
2020-01-13 20:51:40 +00:00
|
|
|
}
|
|
|
|
if ixn.DestinationNS == "" {
|
2021-09-08 15:59:30 +00:00
|
|
|
ixn.DestinationNS = ns
|
2020-01-13 20:51:40 +00:00
|
|
|
}
|
2021-09-08 15:59:30 +00:00
|
|
|
|
|
|
|
ixn.SourcePartition = ""
|
|
|
|
ixn.DestinationPartition = ""
|
2020-01-13 20:51:40 +00:00
|
|
|
}
|
2023-05-25 16:18:55 +00:00
|
|
|
|
|
|
|
func (ixn *Intention) SourcePartitionOrDefault() string {
|
|
|
|
return "default"
|
|
|
|
}
|