utils

package
v0.0.15 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2023 License: MIT Imports: 23 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 (
	// MaxTries is the maximum number of retries to AWS API
	MaxTries = 3
	// Sleep is the amount of time we wait before retrying
	Sleep = 1 * 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
)

Variables

View Source
var (
	// Mutex is used for mutual exclusion
	Mutex sync.Mutex
	// Names contains all the secrets
	Names = make(map[string]struct{})
)

Functions

func ConstraintMacaroon

func ConstraintMacaroon(macHex string, duration time.Duration) (string, error)

ConstraintMacaroon - adds a time constraint for duration since now on the macaroon

func DeleteSecret

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

DeleteSecret - deletes a secret - Deprecated since you cannot reuse same secret name in 7 days

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 GetSecret

func GetSecret(ctx context.Context, arn string) (string, string, error)

GetSecret - gets secret by arn

func InvalidateSecret

func InvalidateSecret(ctx context.Context, name string) (string, error)

InvalidateSecret - is used as a replacement for DeleteSecret

func InvalidateSecretDummy

func InvalidateSecretDummy(ctx context.Context, name string) (string, error)

InvalidateSecretDummy - mock version of the InvalidateSecret method

func InvalidateSecretWithRetries

func InvalidateSecretWithRetries(ctx context.Context, name string) (string, error)

InvalidateSecretWithRetries calls InvalidateSecret with retry logic

func LoadSecrets

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

LoadSecrets - loads all secrets (used at startup)

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 Change

type Change int

Change enum

const (
	Undefined Change = iota
	Inserted
	Updated
)

Change enum values

func InsertOrUpdateSecret

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

InsertOrUpdateSecret - inserts or updates a secret

func InsertOrUpdateSecretWithRetries

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

InsertOrUpdateSecretWithRetries - calls InsertOrUpdateSecret with retry logic

func InsertSecretDummy

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

InsertSecretDummy - mock version of the InsertSecret method

type DeleteSecretSignature

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

DeleteSecretSignature is the signature of a function

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 InsertOrUpdateSecretSignature

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

InsertOrUpdateSecretSignature is the signature of a function

Jump to

Keyboard shortcuts

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