secretsmanager

package
v0.0.0-...-a66ad4e Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2023 License: MIT Imports: 8 Imported by: 2

Documentation

Index

Constants

View Source
const (
	StepCreate = "createSecret"
	StepSet    = "setSecret"
	StepTest   = "testSecret"
	StepFinish = "finishSecret"
)
View Source
const (
	VersionCurrent  = "AWSCURRENT"
	VersionPrevious = "AWSPREVIOUS"
	VersionPending  = "AWSPENDING"
)

Variables

View Source
var (
	ErrInvalidSecretValue  = errors.New("invalid secret value")
	ErrUnauthorized        = errors.New("unauthorized")
	ErrAuthorizationFailed = errors.New("authorization failed")
)
View Source
var (
	ErrRotationInvalidStep = errors.New("invalid rotation step")
	ErrRotationDisabled    = errors.New("rotation disabled")
)

Functions

This section is empty.

Types

type Authorizer

type Authorizer interface {
	Authorize(ctx context.Context, secretID, value string) (err error, remoteCalled bool)
}

type AuthorizerConfig

type AuthorizerConfig struct {
	// gracePreriod is used to tolerate accepting "Previous" and "Pending" secret version
	// as valid values for a short period of time.
	GracePeriod time.Duration

	// coolDownPeriod is period during which we assume the secret can't be rotated.
	// It's used to rate limit the API calls
	CoolDownPeriod time.Duration
}

type BlackList

type BlackList map[string]struct{}

type DefaultAuthorizer

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

func NewAuthorizer

func NewAuthorizer(cli ClientAPI, j *Janitor, opts ...func(*AuthorizerConfig)) *DefaultAuthorizer

func (*DefaultAuthorizer) Authorize

func (a *DefaultAuthorizer) Authorize(ctx context.Context, secretID, value string) (error, bool)

type DefaultRotator

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

DefaultRotator implements Rotator

func NewDefaultRotator

func NewDefaultRotator(cli ClientAPI) *DefaultRotator

func (*DefaultRotator) Create

func (r *DefaultRotator) Create(ctx context.Context, secretARN string, token string) error

Create implements Rotator.

func (*DefaultRotator) Finish

func (r *DefaultRotator) Finish(ctx context.Context, secretARN string, token string) error

Finish implements Rotator.

func (*DefaultRotator) RotationEnabled

func (r *DefaultRotator) RotationEnabled(ctx context.Context, secretARN string) error

func (*DefaultRotator) Set

func (r *DefaultRotator) Set(ctx context.Context, secretARN string, token string, fn func(ctx context.Context, current, pending string) error) error

Set implements Rotator.

func (*DefaultRotator) Test

func (r *DefaultRotator) Test(ctx context.Context, secretARN, token string, fn func(ctx context.Context, pending string) error) error

Test implements Rotator.

type Janitor

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

func NewJanitor

func NewJanitor(interval time.Duration) *Janitor

func (*Janitor) Run

func (j *Janitor) Run(ctx context.Context, onCleanup func())

type MockAuthorizer

type MockAuthorizer struct {
	AuthorizeFn func(ctx context.Context, secretID, value string) (error, bool)
}

MockAuthorizer is a mock implementation of the Updater interface.

func (*MockAuthorizer) Authorize

func (m *MockAuthorizer) Authorize(ctx context.Context, secretID, value string) (error, bool)

Update mocks the Update method.

type MockClient

func (*MockClient) DescribeSecret

DescribeSecret implements ClientAPI.

func (*MockClient) GetSecretValue

GetSecretValue implements ClientAPI.

func (*MockClient) PutSecretValue

PutSecretValue implements ClientAPI.

func (*MockClient) UpdateSecretVersionStage

UpdateSecretVersionStage implements ClientAPI.

type MockRotator

type MockRotator struct {
	RotationEnabledFn func(ctx context.Context, secretARN string) error
	CreateFn          func(ctx context.Context, secretARN, token string) error
	SetFn             func(ctx context.Context, secretARN, token string, fn func(ctx context.Context, current, pending string) error) error
	TestFn            func(ctx context.Context, secretARN, token string, fn func(ctx context.Context, pending string) error) error
	FinishFn          func(ctx context.Context, secretARN, token string) error
}

MockRotator is a mock implementation of the Rotator interface.

func (*MockRotator) Create

func (m *MockRotator) Create(ctx context.Context, secretARN, token string) error

Create mocks the Create method.

func (*MockRotator) Finish

func (m *MockRotator) Finish(ctx context.Context, secretARN, token string) error

Finish mocks the Finish method.

func (*MockRotator) RotationEnabled

func (m *MockRotator) RotationEnabled(ctx context.Context, secretARN string) error

RotationEnabled mocks the RotationEnabled method.

func (*MockRotator) Set

func (m *MockRotator) Set(ctx context.Context, secretARN, token string, fn func(ctx context.Context, current, pending string) error) error

Set mocks the Set method.

func (*MockRotator) Test

func (m *MockRotator) Test(ctx context.Context, secretARN, token string, fn func(ctx context.Context, pending string) error) error

Test mocks the Test method.

type Rotator

type Rotator interface {
	RotationEnabled(ctx context.Context, secretARN string) error
	Create(ctx context.Context, secretARN, token string) error
	Set(ctx context.Context, secretARN, token string, fn func(ctx context.Context, current, pending string) error) error
	Test(ctx context.Context, secretARN, token string, fn func(ctx context.Context, pending string) error) error
	Finish(ctx context.Context, secretARN, token string) error
}

Rotator interface presents a service that is able to:

  • Create new version of a secretsmanager secret;
  • Update downstream services/resources to use the new version;
  • Test the newly updated version of the secret within the scope of the related services/resources

Jump to

Keyboard shortcuts

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