token

package
v1.16.109 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2023 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config added in v1.16.100

type Config struct {
	EnablePersistence              bool
	DataDir                        string
	ACLDefaultToken                string
	ACLAgentToken                  string
	ACLAgentRecoveryToken          string
	ACLReplicationToken            string
	ACLConfigFileRegistrationToken string

	EnterpriseConfig
}

Config used by Store.Load, which includes tokens and settings for persistence.

type EnterpriseConfig added in v1.16.100

type EnterpriseConfig struct {
}

type Logger added in v1.16.100

type Logger interface {
	Warn(msg string, args ...interface{})
}

Logger used by Store.Load to report warnings.

type Notifier added in v1.16.100

type Notifier struct {
	Ch <-chan struct{}
	// contains filtered or unexported fields
}

Notifier holds the channel used to notify a watcher of token updates as well as some internal tracking information to allow for deregistering the notifier.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is used to hold the special ACL tokens used by Consul agents. It is designed to update the tokens on the fly, so the token store itself should be plumbed around and used to get tokens at runtime, don't save the resulting tokens.

func (*Store) AgentRecoveryToken added in v1.16.100

func (t *Store) AgentRecoveryToken() string

func (*Store) AgentRecoveryTokenAndSource added in v1.16.100

func (t *Store) AgentRecoveryTokenAndSource() (string, TokenSource)

func (*Store) AgentToken

func (t *Store) AgentToken() string

AgentToken returns the best token to use for internal agent operations.

func (*Store) AgentTokenAndSource added in v1.4.3

func (t *Store) AgentTokenAndSource() (string, TokenSource)

AgentToken returns the best token to use for internal agent operations.

func (*Store) ConfigFileRegistrationToken added in v1.16.100

func (t *Store) ConfigFileRegistrationToken() string

func (*Store) ConfigFileRegistrationTokenAndSource added in v1.16.100

func (t *Store) ConfigFileRegistrationTokenAndSource() (string, TokenSource)

func (*Store) IsAgentRecoveryToken added in v1.16.100

func (t *Store) IsAgentRecoveryToken(token string) bool

IsAgentRecoveryToken checks to see if a given token is the agent recovery token. This will never match an empty token for safety.

func (*Store) Load added in v1.16.100

func (t *Store) Load(cfg Config, logger Logger) error

Load tokens from Config and optionally from a persisted file in the cfg.DataDir. If a token exists in both the persisted file and in the Config a warning will be logged and the persisted token will be used.

Failures to load the persisted file will result in loading tokens from the config before returning the error.

func (*Store) Notify added in v1.16.100

func (t *Store) Notify(kind TokenKind) Notifier

Notify will set up a watch for when tokens of the desired kind is changed

func (*Store) ReplicationToken added in v1.4.3

func (t *Store) ReplicationToken() string

ReplicationToken returns the replication token.

func (*Store) ReplicationTokenAndSource added in v1.4.3

func (t *Store) ReplicationTokenAndSource() (string, TokenSource)

ReplicationTokenAndSource returns the replication token and its source.

func (*Store) StopNotify added in v1.16.100

func (t *Store) StopNotify(n Notifier)

StopNotify stops the token store from sending notifications to the specified notifiers chan

func (*Store) UpdateAgentRecoveryToken added in v1.16.100

func (t *Store) UpdateAgentRecoveryToken(token string, source TokenSource) bool

UpdateAgentRecoveryToken replaces the current agent recovery token in the store. Returns true if it was changed.

func (*Store) UpdateAgentToken

func (t *Store) UpdateAgentToken(token string, source TokenSource) bool

UpdateAgentToken replaces the current agent token in the store. Returns true if it was changed.

func (*Store) UpdateConfigFileRegistrationToken added in v1.16.100

func (t *Store) UpdateConfigFileRegistrationToken(token string, source TokenSource) bool

UpdateConfigFileRegistrationToken replaces the current config file registration token in the store. Returns true if it was changed.

func (*Store) UpdateReplicationToken added in v1.4.3

func (t *Store) UpdateReplicationToken(token string, source TokenSource) bool

UpdateReplicationToken replaces the current replication token in the store. Returns true if it was changed.

func (*Store) UpdateUserToken

func (t *Store) UpdateUserToken(token string, source TokenSource) bool

UpdateUserToken replaces the current user token in the store. Returns true if it was changed.

func (*Store) UserToken

func (t *Store) UserToken() string

UserToken returns the best token to use for user operations.

func (*Store) UserTokenAndSource added in v1.4.3

func (t *Store) UserTokenAndSource() (string, TokenSource)

UserToken returns the best token to use for user operations.

func (*Store) WithPersistenceLock added in v1.16.100

func (t *Store) WithPersistenceLock(f func() error) error

WithPersistenceLock executes f while hold a lock. If f returns a nil error, the tokens in Store will be persisted to the tokens file. Otherwise no tokens will be persisted, and the error from f will be returned.

The lock is held so that the writes are persisted before some other thread can change the value.

type TokenKind added in v1.16.100

type TokenKind int
const (
	TokenKindAgent TokenKind = iota
	TokenKindAgentRecovery
	TokenKindUser
	TokenKindReplication
	TokenKindConfigFileRegistration
)

type TokenSource added in v1.4.3

type TokenSource bool
const (
	TokenSourceConfig TokenSource = false
	TokenSourceAPI    TokenSource = true
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL