2023-03-15 19:00:52 +03:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2024-01-02 21:36:20 +03:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-15 19:00:52 +03:00
|
|
|
|
2022-01-05 21:02:03 +03:00
|
|
|
//go:build !enterprise
|
2018-09-18 06:03:00 +03:00
|
|
|
|
|
|
|
package vault
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2022-02-18 00:08:51 +03:00
|
|
|
"fmt"
|
2018-09-18 06:03:00 +03:00
|
|
|
|
2022-02-18 00:08:51 +03:00
|
|
|
"github.com/hashicorp/go-hclog"
|
2018-09-18 06:03:00 +03:00
|
|
|
"github.com/hashicorp/vault/helper/namespace"
|
2019-04-13 10:44:06 +03:00
|
|
|
"github.com/hashicorp/vault/sdk/helper/license"
|
2019-04-13 00:54:35 +03:00
|
|
|
"github.com/hashicorp/vault/sdk/logical"
|
|
|
|
"github.com/hashicorp/vault/sdk/physical"
|
2020-06-27 00:13:16 +03:00
|
|
|
"github.com/hashicorp/vault/vault/quotas"
|
2019-02-15 05:14:56 +03:00
|
|
|
"github.com/hashicorp/vault/vault/replication"
|
2018-09-18 06:03:00 +03:00
|
|
|
)
|
|
|
|
|
2020-10-30 02:47:34 +03:00
|
|
|
const (
|
|
|
|
activityLogEnabledDefault = false
|
|
|
|
activityLogEnabledDefaultValue = "default-disabled"
|
|
|
|
)
|
|
|
|
|
2021-04-08 19:43:39 +03:00
|
|
|
type (
|
|
|
|
entCore struct{}
|
|
|
|
entCoreConfig struct{}
|
|
|
|
)
|
2020-02-15 03:39:13 +03:00
|
|
|
|
|
|
|
func (e entCoreConfig) Clone() entCoreConfig {
|
|
|
|
return entCoreConfig{}
|
|
|
|
}
|
2018-09-18 06:03:00 +03:00
|
|
|
|
2019-04-11 18:18:32 +03:00
|
|
|
type LicensingConfig struct {
|
|
|
|
AdditionalPublicKeys []interface{}
|
|
|
|
}
|
2018-09-18 06:03:00 +03:00
|
|
|
|
|
|
|
func coreInit(c *Core, conf *CoreConfig) error {
|
|
|
|
phys := conf.Physical
|
|
|
|
_, txnOK := phys.(physical.Transactional)
|
|
|
|
sealUnwrapperLogger := conf.Logger.Named("storage.sealunwrapper")
|
2023-11-04 00:40:17 +03:00
|
|
|
c.allLoggers = append(c.allLoggers, sealUnwrapperLogger)
|
2018-09-18 06:03:00 +03:00
|
|
|
c.sealUnwrapper = NewSealUnwrapper(phys, sealUnwrapperLogger)
|
|
|
|
// Wrap the physical backend in a cache layer if enabled
|
|
|
|
cacheLogger := c.baseLogger.Named("storage.cache")
|
2023-11-04 00:40:17 +03:00
|
|
|
c.allLoggers = append(c.allLoggers, cacheLogger)
|
2018-09-18 06:03:00 +03:00
|
|
|
if txnOK {
|
2020-10-13 18:11:54 +03:00
|
|
|
c.physical = physical.NewTransactionalCache(c.sealUnwrapper, conf.CacheSize, cacheLogger, c.MetricSink().Sink)
|
2018-09-18 06:03:00 +03:00
|
|
|
} else {
|
2020-10-13 18:11:54 +03:00
|
|
|
c.physical = physical.NewCache(c.sealUnwrapper, conf.CacheSize, cacheLogger, c.MetricSink().Sink)
|
2018-09-18 06:03:00 +03:00
|
|
|
}
|
|
|
|
c.physicalCache = c.physical.(physical.ToggleablePurgemonster)
|
|
|
|
|
2018-11-20 00:13:16 +03:00
|
|
|
// Wrap in encoding checks
|
|
|
|
if !conf.DisableKeyEncodingChecks {
|
|
|
|
c.physical = physical.NewStorageEncoding(c.physical)
|
|
|
|
}
|
2022-10-13 16:59:07 +03:00
|
|
|
|
2018-09-18 06:03:00 +03:00
|
|
|
return nil
|
|
|
|
}
|
2021-04-08 19:43:39 +03:00
|
|
|
|
2020-02-15 03:39:13 +03:00
|
|
|
func (c *Core) setupReplicationResolverHandler() error {
|
|
|
|
return nil
|
|
|
|
}
|
2018-09-18 06:03:00 +03:00
|
|
|
|
2022-02-18 00:08:51 +03:00
|
|
|
func NewPolicyMFABackend(core *Core, logger hclog.Logger) *PolicyMFABackend { return nil }
|
|
|
|
|
|
|
|
func (c *Core) barrierViewForNamespace(namespaceId string) (*BarrierView, error) {
|
|
|
|
if namespaceId != namespace.RootNamespaceID {
|
|
|
|
return nil, fmt.Errorf("failed to find barrier view for non-root namespace")
|
|
|
|
}
|
|
|
|
|
|
|
|
return c.systemBarrierView, nil
|
|
|
|
}
|
|
|
|
|
2022-10-06 21:24:16 +03:00
|
|
|
func (c *Core) UndoLogsEnabled() bool { return false }
|
|
|
|
func (c *Core) UndoLogsPersisted() (bool, error) { return false, nil }
|
2023-10-11 21:14:21 +03:00
|
|
|
func (c *Core) EnableUndoLogs() {}
|
2022-10-06 21:24:16 +03:00
|
|
|
func (c *Core) PersistUndoLogs() error { return nil }
|
|
|
|
|
2020-02-15 03:39:13 +03:00
|
|
|
func (c *Core) teardownReplicationResolverHandler() {}
|
2023-10-16 14:38:11 +03:00
|
|
|
func (c *Core) createSecondaries(_ hclog.Logger) {}
|
2018-09-18 06:03:00 +03:00
|
|
|
|
2023-10-16 14:38:11 +03:00
|
|
|
func (c *Core) addExtraLogicalBackends(_ string) {}
|
2018-09-18 06:03:00 +03:00
|
|
|
|
2023-10-16 14:38:11 +03:00
|
|
|
func (c *Core) addExtraCredentialBackends() {}
|
2018-09-18 06:03:00 +03:00
|
|
|
|
|
|
|
func preUnsealInternal(context.Context, *Core) error { return nil }
|
|
|
|
|
2020-06-29 20:23:10 +03:00
|
|
|
func postSealInternal(*Core) {}
|
2018-09-18 06:03:00 +03:00
|
|
|
|
|
|
|
func preSealPhysical(c *Core) {
|
|
|
|
switch c.sealUnwrapper.(type) {
|
|
|
|
case *sealUnwrapper:
|
|
|
|
c.sealUnwrapper.(*sealUnwrapper).stopUnwraps()
|
|
|
|
case *transactionalSealUnwrapper:
|
|
|
|
c.sealUnwrapper.(*transactionalSealUnwrapper).stopUnwraps()
|
|
|
|
}
|
|
|
|
|
|
|
|
// Purge the cache
|
|
|
|
c.physicalCache.SetEnabled(false)
|
|
|
|
c.physicalCache.Purge(context.Background())
|
|
|
|
}
|
|
|
|
|
|
|
|
func postUnsealPhysical(c *Core) error {
|
|
|
|
switch c.sealUnwrapper.(type) {
|
|
|
|
case *sealUnwrapper:
|
|
|
|
c.sealUnwrapper.(*sealUnwrapper).runUnwraps()
|
|
|
|
case *transactionalSealUnwrapper:
|
|
|
|
c.sealUnwrapper.(*transactionalSealUnwrapper).runUnwraps()
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-05-06 01:53:57 +03:00
|
|
|
func loadPolicyMFAConfigs(context.Context, *Core) error { return nil }
|
2018-09-18 06:03:00 +03:00
|
|
|
|
|
|
|
func shouldStartClusterListener(*Core) bool { return true }
|
|
|
|
|
|
|
|
func hasNamespaces(*Core) bool { return false }
|
|
|
|
|
|
|
|
func (c *Core) Features() license.Features {
|
|
|
|
return license.FeatureNone
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Core) HasFeature(license.Features) bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2019-10-08 20:58:19 +03:00
|
|
|
func (c *Core) collectNamespaces() []*namespace.Namespace {
|
|
|
|
return []*namespace.Namespace{
|
|
|
|
namespace.RootNamespace,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-17 22:43:07 +03:00
|
|
|
func (c *Core) HasWALState(required *logical.WALState, perfStandby bool) bool {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
2019-02-15 05:14:56 +03:00
|
|
|
func (c *Core) setupReplicatedClusterPrimary(*replication.Cluster) error { return nil }
|
2018-09-18 06:03:00 +03:00
|
|
|
|
|
|
|
func (c *Core) perfStandbyCount() int { return 0 }
|
|
|
|
|
2019-10-27 23:30:38 +03:00
|
|
|
func (c *Core) removePathFromFilteredPaths(context.Context, string, string) error {
|
2018-09-18 06:03:00 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Core) checkReplicatedFiltering(context.Context, *MountEntry, string) (bool, error) {
|
|
|
|
return false, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Core) invalidateSentinelPolicy(PolicyType, string) {}
|
|
|
|
|
|
|
|
func (c *Core) removePerfStandbySecondary(context.Context, string) {}
|
2019-02-15 05:14:56 +03:00
|
|
|
|
2019-07-24 23:32:57 +03:00
|
|
|
func (c *Core) removeAllPerfStandbySecondaries() {}
|
|
|
|
|
2019-11-07 01:36:47 +03:00
|
|
|
func (c *Core) perfStandbyClusterHandler() (*replication.Cluster, chan struct{}, error) {
|
|
|
|
return nil, make(chan struct{}), nil
|
2019-02-15 05:14:56 +03:00
|
|
|
}
|
2019-10-15 22:48:23 +03:00
|
|
|
|
|
|
|
func (c *Core) initSealsForMigration() {}
|
2019-10-16 19:52:37 +03:00
|
|
|
|
|
|
|
func (c *Core) postSealMigration(ctx context.Context) error { return nil }
|
2020-06-27 00:13:16 +03:00
|
|
|
|
2021-09-02 17:54:21 +03:00
|
|
|
func (c *Core) applyLeaseCountQuota(_ context.Context, in *quotas.Request) (*quotas.Response, error) {
|
2020-06-27 00:13:16 +03:00
|
|
|
return "as.Response{Allowed: true}, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Core) ackLeaseQuota(access quotas.Access, leaseGenerated bool) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Core) quotaLeaseWalker(ctx context.Context, callback func(request *quotas.Request) bool) error {
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2022-07-05 20:02:00 +03:00
|
|
|
func (c *Core) quotasHandleLeases(ctx context.Context, action quotas.LeaseAction, leases []*quotas.QuotaLeaseInformation) error {
|
2020-06-27 00:13:16 +03:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *Core) namespaceByPath(path string) *namespace.Namespace {
|
|
|
|
return namespace.RootNamespace
|
|
|
|
}
|
2021-02-24 14:58:10 +03:00
|
|
|
|
|
|
|
func (c *Core) AllowForwardingViaHeader() bool {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
2022-02-17 22:43:07 +03:00
|
|
|
func (c *Core) ForwardToActive() string {
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
2021-06-11 20:18:16 +03:00
|
|
|
func (c *Core) MissingRequiredState(raw []string, perfStandby bool) bool {
|
2021-02-24 14:58:10 +03:00
|
|
|
return false
|
|
|
|
}
|
2021-06-26 00:18:34 +03:00
|
|
|
|
2021-08-02 20:50:49 +03:00
|
|
|
func DiagnoseCheckLicense(ctx context.Context, vaultCore *Core, coreConfig CoreConfig, generate bool) (bool, []string) {
|
2021-06-26 00:18:34 +03:00
|
|
|
return false, nil
|
|
|
|
}
|