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 ¶
- type AutoConfig
- type GracePeriod
- type InitialCredentials
- type Rotator
- func (r *Rotator) AllCredentials() []SDKCredential
- func (r *Rotator) DeprecatedCredentials() []SDKCredential
- func (r *Rotator) EnvironmentID() config.EnvironmentID
- func (r *Rotator) Initialize(credentials []SDKCredential)
- func (r *Rotator) MobileKey() config.MobileKey
- func (r *Rotator) PrimaryCredentials() []SDKCredential
- func (r *Rotator) Rotate(cred SDKCredential)
- func (r *Rotator) RotateWithGrace(primary SDKCredential, grace *GracePeriod)
- func (r *Rotator) SDKKey() config.SDKKey
- func (r *Rotator) StepTime(now time.Time) (additions []SDKCredential, expirations []SDKCredential)
- type SDKCredential
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
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 Rotator ¶ added in v8.8.0
type Rotator struct {
// contains filtered or unexported fields
}
func NewRotator ¶ added in v8.8.0
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) 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) 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.).