cfaws

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeout error = errors.New("polling for device authorization token timed out")

Functions

func ClearSSOToken

func ClearSSOToken(profileKey string)

Attempts to clear the token, any errors will be logged to debug logging

func PollToken

func PollToken(ctx context.Context, c *ssooidc.Client, clientSecret string, clientID string, deviceCode string, cfg PollingConfig) (*ssooidc.CreateTokenOutput, error)

PollToken will poll for a token and return it once the authentication/authorization flow has been completed in the browser

func StoreSSOToken

func StoreSSOToken(profileKey string, ssoTokenValue SSOToken)

Attempts to store the token, any errors will be logged to debug logging

func TypeCredsToAwsCreds

func TypeCredsToAwsCreds(c types.Credentials) aws.Credentials

func TypeRoleCredsToAwsCreds

func TypeRoleCredsToAwsCreds(c ssotypes.RoleCredentials) aws.Credentials

func UpdateFrecencyCache

func UpdateFrecencyCache(selectedProfile string)

use this to update frecency cache when the profile is supplied by the commandline

Types

type CFSharedConfig

type CFSharedConfig struct {
	// the original config, some values may be empty strings depending on the type or profile
	RawConfig   config.SharedConfig
	Name        string
	ProfileType ProfileType
	// ordered from root to direct parent profile
	Parents []*CFSharedConfig
}

func (*CFSharedConfig) Assume

func (c *CFSharedConfig) Assume(ctx context.Context) (aws.Credentials, error)

func (*CFSharedConfig) AwsConfig

func (c *CFSharedConfig) AwsConfig(ctx context.Context, useSSORegion bool) (aws.Config, error)

func (*CFSharedConfig) CallerIdentity

func (c *CFSharedConfig) CallerIdentity(ctx context.Context) (*sts.GetCallerIdentityOutput, error)

func (CFSharedConfig) Region

func (c CFSharedConfig) Region(ctx context.Context) (string, bool, error)

Region will attempt to load the reason on this profile, if it is not set, attempts to load the default config returns a region, and bool = true if the default region was used

func (*CFSharedConfig) SSOLogin

func (c *CFSharedConfig) SSOLogin(ctx context.Context) (aws.Credentials, error)

type CFSharedConfigs

type CFSharedConfigs map[string]*CFSharedConfig

func GetProfilesFromDefaultSharedConfig

func GetProfilesFromDefaultSharedConfig(ctx context.Context) (CFSharedConfigs, error)

GetProfilesFromDefaultSharedConfig returns initialised profiles these profiles state their type and parents

func (CFSharedConfigs) GetFrecentProfiles

func (c CFSharedConfigs) GetFrecentProfiles() (*FrecentProfiles, []string)

loads the frecency cache and generates a list of profiles with frecently used profiles first, followed by alphabetically sorted profiles that have not been used with assume this method returns a FrecentProfiles pointer which should be used after selecting a profile to update the cache, it will also remove any entries which no longer exist in the aws config

func (CFSharedConfigs) IAMProfileNames

func (c CFSharedConfigs) IAMProfileNames() []string

func (CFSharedConfigs) ProfileNames

func (c CFSharedConfigs) ProfileNames() []string

func (CFSharedConfigs) SSOProfileNames

func (c CFSharedConfigs) SSOProfileNames() []string

type CredProv

type CredProv struct{ aws.Credentials }

CredProv implements the aws.CredentialProvider interface

func (*CredProv) Retrieve

func (c *CredProv) Retrieve(ctx context.Context) (aws.Credentials, error)

type FrecentProfiles

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

func (*FrecentProfiles) Update

func (f *FrecentProfiles) Update(selectedProfile string)

should be called after selecting a profile to update frecency cache wrap this method in a go routine to avoid blocking the user

type PollingConfig

type PollingConfig struct {
	CheckInterval time.Duration
	TimeoutAfter  time.Duration
}

type ProfileType

type ProfileType int
const (
	ProfileTypeSSO ProfileType = iota
	ProfileTypeIAM
)

type SSOToken

type SSOToken struct {
	AccessToken string
	Expiry      time.Time
}

func GetValidCachedToken

func GetValidCachedToken(profileKey string) *SSOToken

GetValidCachedToken returns nil if no token was found, or if it is expired

func SSODeviceCodeFlow

func SSODeviceCodeFlow(ctx context.Context, cfg aws.Config, rootProfile *CFSharedConfig) (*SSOToken, error)

SSODeviceCodeFlow contains all the steps to complete a device code flow to retrieve an sso token

Jump to

Keyboard shortcuts

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