utils

package
v0.0.19 Latest Latest
Warning

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

Go to latest
Published: May 29, 2023 License: MIT Imports: 35 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// PresignHeader - HTTP Header for pre-signed requests
	PresignHeader = "X-Amazon-Presigned-Getcalleridentity"
	// EmptyBodyHash - Hash of empty body
	EmptyBodyHash = "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855"
)
View Source
const (
	// DefaultCacheTime should be lower than token validity
	DefaultCacheTime = 2 * time.Minute
	// DefaultValidity is the default for new tokens
	DefaultValidity = 5 * time.Minute

	// HTTPRetryTime for doing the check on AWS STS
	HTTPRetryTime = 3 * time.Second
)
View Source
const (
	// Delimiter between entries
	Delimiter = ","
	// UserPassSeparator separates username from password (cannot use :)
	UserPassSeparator = "|"
	// IAMAuthFlag defines that IAM authentication should be used
	IAMAuthFlag = "$iam" // starts with $ so it's an invalid crypted password
)
View Source
const MaxRetryTime = 30 * time.Second

MaxRetryTime is the maximum time we will retry calls

Variables

This section is empty.

Functions

func Constrain added in v0.0.16

func Constrain(original string, duration time.Duration, defaultAPIType *api.APIType) (string, error)

Constrain constrains a given authenticator

func GetConstrained

func GetConstrained(d *entities.Data, duration time.Duration) entities.Data

GetConstrained returns a constrained version of d (macaroon will be time constrained)

func GetData

func GetData(name string, uniqueID string) (*entities.Data, error)

GetData - obtain data from vault

func GetGCPProjectID added in v0.0.19

func GetGCPProjectID() (string, error)

GetGCPProjectID - get GCP project id from workstation

func PresignGetCallerIdentity

func PresignGetCallerIdentity(validity time.Duration) (string, error)

PresignGetCallerIdentity will sign a query string to retrieve my caller identity by third party. Returns: - the query string - error (when not successful)

func VerifyGetCallerIdentity

func VerifyGetCallerIdentity(query string, timeout time.Duration) (string, error)

VerifyGetCallerIdentity will verify that query string received is actually a presigned URL to sts/GetCallerIdentity. Returns:

  • ARN of the identity when successful
  • error else

Types

type AuthenticatorType added in v0.0.16

type AuthenticatorType int

AuthenticatorType enum

const (
	Unknown AuthenticatorType = iota
	Macaroon
	Rune
)

AuthenticatorType values

func DetectAuthenticatorType added in v0.0.16

func DetectAuthenticatorType(str string, whenMultipleMatch *api.APIType) AuthenticatorType

DetectAuthenticatorType detects what kind of authenticator is used

func ToAuthenticatorType added in v0.0.16

func ToAuthenticatorType(t api.APIType) AuthenticatorType

ToAuthenticatorType returns what kind of authenticator a given API uses

type AwsSecretsManager added in v0.0.19

type AwsSecretsManager struct {
}

AwsSecretsManager struct.

func NewAwsSecretsManager added in v0.0.19

func NewAwsSecretsManager() *AwsSecretsManager

NewAwsSecretsManager creates a new AwsSecretsManager

func (*AwsSecretsManager) DeleteSecret added in v0.0.19

func (s *AwsSecretsManager) DeleteSecret(ctx context.Context, name string) (string, error)

DeleteSecret - deletes a secret

func (*AwsSecretsManager) InsertOrUpdateSecret added in v0.0.19

func (s *AwsSecretsManager) InsertOrUpdateSecret(ctx context.Context, name, value string) (string, Change, error)

InsertOrUpdateSecret - inserts or updates a secret

func (*AwsSecretsManager) LoadSecrets added in v0.0.19

func (s *AwsSecretsManager) LoadSecrets(ctx context.Context, prefix string) map[string]string

LoadSecrets - loads all secrets (used at startup)

type Change

type Change int

Change enum

const (
	Undefined Change = iota
	Inserted
	Updated
)

Change enum values

type CloudProvider added in v0.0.19

type CloudProvider int

CloudProvider enum.

const (
	UnknownProvider CloudProvider = iota
	AWS
	GCP
)

CloudProvider enum values.

func DetermineProvider added in v0.0.19

func DetermineProvider() CloudProvider

DetermineProvider tries to determine the cloud provider or uses CLOUD_PROVIDER environment variable

type ConstrainFunc added in v0.0.16

type ConstrainFunc func(string, time.Duration) (string, error)

ConstrainFunc is the method signature

type DeleteSecretFn added in v0.0.19

type DeleteSecretFn func(ctx context.Context, name string) (string, error)

DeleteSecretFn method

type DummySecretsManager added in v0.0.19

type DummySecretsManager struct {
	// Mutex is used for mutual exclusion
	Mutex sync.Mutex
	// Names contains all the secrets
	Names map[string]struct{}
}

DummySecretsManager struct.

func NewDummySecretsManager added in v0.0.19

func NewDummySecretsManager() *DummySecretsManager

NewDummySecretsManager creates a new DummySecretsManager

func (*DummySecretsManager) DeleteSecret added in v0.0.19

func (s *DummySecretsManager) DeleteSecret(ctx context.Context, name string) (string, error)

DeleteSecret - deletes a secret

func (*DummySecretsManager) InsertOrUpdateSecret added in v0.0.19

func (s *DummySecretsManager) InsertOrUpdateSecret(ctx context.Context, name, value string) (string, Change, error)

InsertOrUpdateSecret - inserts or updates a secret

func (*DummySecretsManager) LoadSecrets added in v0.0.19

func (s *DummySecretsManager) LoadSecrets(ctx context.Context, prefix string) map[string]string

LoadSecrets - loads all secrets (used at startup)

type GcpSecretsManager added in v0.0.19

type GcpSecretsManager struct {
}

GcpSecretsManager struct.

func NewGcpSecretsManager added in v0.0.19

func NewGcpSecretsManager() *GcpSecretsManager

NewGcpSecretsManager creates a new GcpSecretsManager

func (*GcpSecretsManager) DeleteSecret added in v0.0.19

func (s *GcpSecretsManager) DeleteSecret(ctx context.Context, name string) (string, error)

DeleteSecret - deletes a secret

func (*GcpSecretsManager) InsertOrUpdateSecret added in v0.0.19

func (s *GcpSecretsManager) InsertOrUpdateSecret(ctx context.Context, name, value string) (string, Change, error)

InsertOrUpdateSecret - inserts or updates a secret

func (*GcpSecretsManager) LoadSecrets added in v0.0.19

func (s *GcpSecretsManager) LoadSecrets(ctx context.Context, prefix string) map[string]string

LoadSecrets - loads all secrets (used at startup)

type GetCallerIdentityResponse

type GetCallerIdentityResponse struct {
	GetCallerIdentityResult GetCallerIdentityResult
}

GetCallerIdentityResponse struct

type GetCallerIdentityResult

type GetCallerIdentityResult struct {
	Arn     string `xml:"Arn"`
	UserID  string `xml:"UserId"`
	Account string `xml:"Account"`
}

GetCallerIdentityResult struct

type InsertOrUpdateSecretData added in v0.0.18

type InsertOrUpdateSecretData struct {
	Arn    string
	Change Change
}

InsertOrUpdateSecretData struct

type InsertOrUpdateSecretFn added in v0.0.19

type InsertOrUpdateSecretFn func(ctx context.Context, name, value string) (string, Change, error)

InsertOrUpdateSecretFn method

type LoadSecretsFn added in v0.0.19

type LoadSecretsFn func(ctx context.Context, prefix string) map[string]string

LoadSecretsFn method

type SecretsManager added in v0.0.19

type SecretsManager interface {
	InsertOrUpdateSecret(ctx context.Context, name, value string) (string, Change, error)
	DeleteSecret(ctx context.Context, name string) (string, error)
	LoadSecrets(ctx context.Context, prefix string) map[string]string
}

SecretsManager interface

func GetPlatformSecretsManager added in v0.0.19

func GetPlatformSecretsManager() SecretsManager

GetPlatformSecretsManager - gets the implementation for the current platform

type TestSecretsManager added in v0.0.19

type TestSecretsManager struct {
	InsertOrUpdateSecretFn InsertOrUpdateSecretFn
	DeleteSecretFn         DeleteSecretFn
	LoadSecretsFn          LoadSecretsFn
	Dummy                  DummySecretsManager
}

TestSecretsManager struct.

func NewTestSecretsManager added in v0.0.19

func NewTestSecretsManager() *TestSecretsManager

NewTestSecretsManager - create a new test secrets manager

func (*TestSecretsManager) DeleteSecret added in v0.0.19

func (s *TestSecretsManager) DeleteSecret(ctx context.Context, name string) (string, error)

DeleteSecret - deletes a secret

func (*TestSecretsManager) InsertOrUpdateSecret added in v0.0.19

func (s *TestSecretsManager) InsertOrUpdateSecret(ctx context.Context, name, value string) (string, Change, error)

InsertOrUpdateSecret - inserts or updates secret

func (*TestSecretsManager) LoadSecrets added in v0.0.19

func (s *TestSecretsManager) LoadSecrets(ctx context.Context, prefix string) map[string]string

LoadSecrets - loads secrets

type URLCloudPair added in v0.0.19

type URLCloudPair struct {
	URL      string
	Provider CloudProvider
	Header   http.Header
}

URLCloudPair struct.

Jump to

Keyboard shortcuts

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