credential

package
v8.10.0 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package credential defines the main SDKCredential interface used throughout the codebase, as well as a means to detect how a credential has changed.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AutoConfig

type AutoConfig struct {
	// SDKKey is the environment's SDK key; if there is more than one active key, it is the latest.
	SDKKey SDKCredential
	// ExpiringSDKKey is an additional SDK key that may or may not be present; it represents the fact that a deprecated
	// key may exist which can still authenticate a given connection.
	ExpiringSDKKey SDKCredential
	// MobileKey is the environment's mobile key.
	MobileKey SDKCredential
}

AutoConfig represents credentials that are updated via AutoConfig protocol.

type GracePeriod added in v8.8.0

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

GracePeriod represents a grace period (or deprecation period) within which a particular SDK key is still valid, pending revocation.

func NewGracePeriod added in v8.8.0

func NewGracePeriod(key config.SDKKey, expiry time.Time, now time.Time) *GracePeriod

NewGracePeriod constructs a new grace period. The current time must be provided in order to determine if the credential is already expired.

func (*GracePeriod) Expired added in v8.8.0

func (g *GracePeriod) Expired() bool

Expired returns true if the key has already expired.

type InitialCredentials added in v8.8.0

type InitialCredentials struct {
	SDKKey        config.SDKKey
	MobileKey     config.MobileKey
	EnvironmentID config.EnvironmentID
}

type Rotator added in v8.8.0

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

func NewRotator added in v8.8.0

func NewRotator(loggers ldlog.Loggers) *Rotator

NewRotator constructs a rotator with the provided loggers. A new rotator contains no credentials and can optionally be initialized via Initialize.

func (*Rotator) AllCredentials added in v8.8.0

func (r *Rotator) AllCredentials() []SDKCredential

AllCredentials returns the primary and deprecated credentials as one list.

func (*Rotator) DeprecatedCredentials added in v8.8.0

func (r *Rotator) DeprecatedCredentials() []SDKCredential

DeprecatedCredentials returns deprecated credentials (not expired or primary.)

func (*Rotator) EnvironmentID added in v8.8.0

func (r *Rotator) EnvironmentID() config.EnvironmentID

EnvironmentID returns the environment ID.

func (*Rotator) Initialize added in v8.8.0

func (r *Rotator) Initialize(credentials []SDKCredential)

Initialize sets the initial credentials. Only credentials that are defined will be stored.

func (*Rotator) MobileKey added in v8.8.0

func (r *Rotator) MobileKey() config.MobileKey

MobileKey returns the primary mobile key.

func (*Rotator) PrimaryCredentials added in v8.8.0

func (r *Rotator) PrimaryCredentials() []SDKCredential

PrimaryCredentials returns the primary (non-deprecated) credentials.

func (*Rotator) Rotate added in v8.8.0

func (r *Rotator) Rotate(cred SDKCredential)

Rotate sets a new primary credential while revoking the previous.

func (*Rotator) RotateWithGrace added in v8.8.0

func (r *Rotator) RotateWithGrace(primary SDKCredential, grace *GracePeriod)

RotateWithGrace sets a new primary credential while deprecating a previous credential. The grace parameter may be nil to immediately revoke the previous credential. It is invalid to specify a grace period when the credential being rotate is a mobile key or environment ID.

func (*Rotator) SDKKey added in v8.8.0

func (r *Rotator) SDKKey() config.SDKKey

SDKKey returns the primary SDK key.

func (*Rotator) StepTime added in v8.8.0

func (r *Rotator) StepTime(now time.Time) (additions []SDKCredential, expirations []SDKCredential)

StepTime provides the current time to the Rotator, allowing it to compute the set of additions and expirations for the tracked credentials since the last time this method was called.

type SDKCredential

type SDKCredential interface {
	// GetAuthorizationHeaderValue returns the value that should be passed in an HTTP Authorization header
	// when using this credential, or "" if the header is not used.
	GetAuthorizationHeaderValue() string
	// Defined returns true if the credential is present.
	Defined() bool
	// String returns the string form of the credential.
	String() string
	// Masked returns a masked form of the credential suitable for log messages.
	Masked() string
}

SDKCredential is implemented by types that represent an SDK authorization credential (SDKKey, etc.).

Jump to

Keyboard shortcuts

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