Documentation ¶
Index ¶
- Variables
- func GetCredentialsCreds(ctx context.Context, c *Profile) (aws.Credentials, error)
- func GetEnvCredentials(ctx context.Context) aws.Credentials
- func IsLegalProfileName(name string) bool
- func IsValidCustomProfile(rawConfig *ini.Section) error
- func LaunchBrowser(url string, profile string, flow string, printOnly bool) error
- func MfaTokenProvider() (string, error)
- func PollToken(ctx context.Context, c *ssooidc.Client, clientSecret string, clientID string, ...) (*ssooidc.CreateTokenOutput, error)
- func RegisterAssumer(a Assumer, position int)
- func SSODeviceCodeFlowFromStartUrl(ctx context.Context, cfg aws.Config, startUrl string, profile string, ...) (*securestorage.SSOToken, error)
- func TypeCredsToAwsCreds(c types.Credentials) aws.Credentials
- func TypeRoleCredsToAwsCreds(c ssotypes.RoleCredentials) aws.Credentials
- func UpdateFrecencyCache(selectedProfile string)
- type Assumer
- type AwsIamAssumer
- func (aia *AwsIamAssumer) AssumeConsole(ctx context.Context, c *Profile, configOpts ConfigOpts) (aws.Credentials, error)
- func (aia *AwsIamAssumer) AssumeTerminal(ctx context.Context, c *Profile, configOpts ConfigOpts) (aws.Credentials, error)
- func (aia *AwsIamAssumer) ProfileMatchesType(rawProfile *ini.Section, parsedProfile config.SharedConfig) bool
- func (aia *AwsIamAssumer) Type() string
- type AwsSsoAssumer
- func (asa *AwsSsoAssumer) AssumeConsole(ctx context.Context, c *Profile, configOpts ConfigOpts) (aws.Credentials, error)
- func (asa *AwsSsoAssumer) AssumeTerminal(ctx context.Context, c *Profile, configOpts ConfigOpts) (aws.Credentials, error)
- func (asa *AwsSsoAssumer) ProfileMatchesType(rawProfile *ini.Section, parsedProfile config.SharedConfig) bool
- func (asa *AwsSsoAssumer) Type() string
- type ConfigOpts
- type CredProv
- type CredentialProcessAssumer
- func (cpa *CredentialProcessAssumer) AssumeConsole(ctx context.Context, c *Profile, configOpts ConfigOpts) (aws.Credentials, error)
- func (cpa *CredentialProcessAssumer) AssumeTerminal(ctx context.Context, c *Profile, configOpts ConfigOpts) (aws.Credentials, error)
- func (cpa *CredentialProcessAssumer) ProfileMatchesType(rawProfile *ini.Section, parsedProfile config.SharedConfig) bool
- func (cpa *CredentialProcessAssumer) Type() string
- type FrecentProfiles
- type PollingConfig
- type Profile
- func (c *Profile) AssumeConsole(ctx context.Context, configOpts ConfigOpts) (aws.Credentials, error)
- func (c *Profile) AssumeTerminal(ctx context.Context, configOpts ConfigOpts) (aws.Credentials, error)
- func (p *Profile) Description() string
- func (p *Profile) InitWithPlainTextSSOToken(ctx context.Context, awsCred aws.Credentials) error
- func (p *Profile) LoadPlainTextSSOToken(ctx context.Context, profile string) (aws.Credentials, error)
- func (p *Profile) Region(ctx context.Context) (string, error)
- func (c *Profile) SSOLogin(ctx context.Context, configOpts ConfigOpts) (aws.Credentials, error)
- type Profiles
- func (p *Profiles) GetFrecentProfiles() (*FrecentProfiles, []string)
- func (p *Profiles) HasProfile(profile string) bool
- func (p *Profiles) InitialiseProfilesTree(ctx context.Context)
- func (p *Profiles) LoadInitialisedProfile(ctx context.Context, profile string) (*Profile, error)
- func (p *Profiles) ParseCustomSSOProfile(ctx context.Context, profile *Profile) (*config.SharedConfig, error)
- func (p *Profiles) Profile(profile string) (*Profile, error)
- type Session
Constants ¶
This section is empty.
Variables ¶
var ErrProfileNotFound error = errors.New("profile not found")
var ErrProfileNotInitialised error = errors.New("profile not initialised")
var ErrTimeout error = errors.New("polling for device authorization token timed out")
Functions ¶
func GetCredentialsCreds ¶
func GetEnvCredentials ¶
func GetEnvCredentials(ctx context.Context) aws.Credentials
loads the environment variables and hydrates an aws.config if they are present
func IsLegalProfileName ¶
Helper function which returns true if provided profile name string does not contain illegal characters
func IsValidCustomProfile ¶
func IsValidCustomProfile(rawConfig *ini.Section) error
We have to make sure the custom prefix is added to the aws config file.
func LaunchBrowser ¶ added in v0.19.0
func MfaTokenProvider ¶
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 RegisterAssumer ¶
RegisterAssumer allows assumers to be registered when using this library as a package in other projects position = -1 will append the assumer position to insert assumer
func SSODeviceCodeFlowFromStartUrl ¶
func SSODeviceCodeFlowFromStartUrl(ctx context.Context, cfg aws.Config, startUrl string, profile string, printOnly bool) (*securestorage.SSOToken, error)
SSODeviceCodeFlowFromStartUrl contains all the steps to complete a device code flow to retrieve an SSO token
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 Assumer ¶
type Assumer interface { // AssumeTerminal should follow the required process for it implemetation and return aws credentials ready to be exported to the terminal environment AssumeTerminal(context.Context, *Profile, ConfigOpts) (aws.Credentials, error) // AssumeConsole should follow any console specific credentials processes, this may be the same as AssumeTerminal under the hood AssumeConsole(context.Context, *Profile, ConfigOpts) (aws.Credentials, error) // A unique key which identifies this assumer e.g AWS-SSO or GOOGLE-AWS-AUTH Type() string // ProfileMatchesType takes a list of strings which are the lines in an aw config profile and returns true if this profile is the assumers type ProfileMatchesType(*ini.Section, config.SharedConfig) bool }
Added support for optional pass through args on proxy sso provider When using a sso provider adding pass through flags can be acheived by adding the -pass-through or -pt flag EG. assume role-a -pt --mode -pt gui (Run the proxy login with a gui rather than in cli. Example taken from aws-azure-login)
func AssumerFromType ¶
type AwsIamAssumer ¶
type AwsIamAssumer struct { }
Implements Assumer
func (*AwsIamAssumer) AssumeConsole ¶
func (aia *AwsIamAssumer) AssumeConsole(ctx context.Context, c *Profile, configOpts ConfigOpts) (aws.Credentials, error)
if required will get a FederationToken to be used to launch the console This is required is the iam profile does not assume a role using sts.AssumeRole
func (*AwsIamAssumer) AssumeTerminal ¶
func (aia *AwsIamAssumer) AssumeTerminal(ctx context.Context, c *Profile, configOpts ConfigOpts) (aws.Credentials, error)
Default behaviour is to use the sdk to retrieve the credentials from the file For launching the console there is an extra step GetFederationToken that happens after this to get a session token
func (*AwsIamAssumer) ProfileMatchesType ¶
func (aia *AwsIamAssumer) ProfileMatchesType(rawProfile *ini.Section, parsedProfile config.SharedConfig) bool
Matches the profile type on whether it is not an sso profile. this will also match other types that are not sso profiles so it should be the last option checked when determining the profile type
func (*AwsIamAssumer) Type ¶
func (aia *AwsIamAssumer) Type() string
A unique key which identifies this assumer e.g AWS-SSO or GOOGLE-AWS-AUTH
type AwsSsoAssumer ¶
type AwsSsoAssumer struct { }
Implements Assumer
func (*AwsSsoAssumer) AssumeConsole ¶
func (asa *AwsSsoAssumer) AssumeConsole(ctx context.Context, c *Profile, configOpts ConfigOpts) (aws.Credentials, error)
func (*AwsSsoAssumer) AssumeTerminal ¶
func (asa *AwsSsoAssumer) AssumeTerminal(ctx context.Context, c *Profile, configOpts ConfigOpts) (aws.Credentials, error)
func (*AwsSsoAssumer) ProfileMatchesType ¶
func (asa *AwsSsoAssumer) ProfileMatchesType(rawProfile *ini.Section, parsedProfile config.SharedConfig) bool
Matches the profile type on whether it is an sso profile by checking for ssoaccountid.
func (*AwsSsoAssumer) Type ¶
func (asa *AwsSsoAssumer) Type() string
type CredProv ¶
type CredProv struct{ aws.Credentials }
CredProv implements the aws.CredentialProvider interface
type CredentialProcessAssumer ¶
type CredentialProcessAssumer struct { }
Implements Assumer using the aws credential_process standard
func (*CredentialProcessAssumer) AssumeConsole ¶
func (cpa *CredentialProcessAssumer) AssumeConsole(ctx context.Context, c *Profile, configOpts ConfigOpts) (aws.Credentials, error)
func (*CredentialProcessAssumer) AssumeTerminal ¶
func (cpa *CredentialProcessAssumer) AssumeTerminal(ctx context.Context, c *Profile, configOpts ConfigOpts) (aws.Credentials, error)
func (*CredentialProcessAssumer) ProfileMatchesType ¶
func (cpa *CredentialProcessAssumer) ProfileMatchesType(rawProfile *ini.Section, parsedProfile config.SharedConfig) bool
inspect for any credential processes with the saml2aws tool
func (*CredentialProcessAssumer) Type ¶
func (cpa *CredentialProcessAssumer) Type() string
A unique key which identifies this assumer e.g AWS-SSO or GOOGLE-AWS-AUTH
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 Profile ¶
type Profile struct { // allows access to the raw values from the file RawConfig *ini.Section Name string // the file that this profile is from File string ProfileType string // ordered from root to direct parent profile Parents []*Profile // the original config, some values may be empty strings depending on the type or profile AWSConfig config.SharedConfig Initialised bool LoadingError error HasSecureStorageIAMCredentials bool CustomDescriptionKey string }
func (*Profile) AssumeConsole ¶
func (c *Profile) AssumeConsole(ctx context.Context, configOpts ConfigOpts) (aws.Credentials, error)
func (*Profile) AssumeTerminal ¶
func (c *Profile) AssumeTerminal(ctx context.Context, configOpts ConfigOpts) (aws.Credentials, error)
func (*Profile) Description ¶
if the profile has a custom description key, the value is returned. else an empty string
func (*Profile) InitWithPlainTextSSOToken ¶
Initialize profile's AWS config by fetching credentials from plain-text-SSO-token located at default cache directory.
func (*Profile) LoadPlainTextSSOToken ¶
func (p *Profile) LoadPlainTextSSOToken(ctx context.Context, profile string) (aws.Credentials, error)
Make sure credentials are available and valid.
func (*Profile) Region ¶
Region will attempt to load the reason on this profile, if it is not set, attempt to load the parent if it exists else attempts to use the sso-region else attempts to load the default config returns a region, and bool = true if the default region was used
func (*Profile) SSOLogin ¶
func (c *Profile) SSOLogin(ctx context.Context, configOpts ConfigOpts) (aws.Credentials, error)
type Profiles ¶
type Profiles struct { // alphabetically sorted after first load ProfileNames []string SessionNames []string // contains filtered or unexported fields }
func LoadProfiles ¶
func (*Profiles) GetFrecentProfiles ¶
func (p *Profiles) 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 (*Profiles) HasProfile ¶
func (*Profiles) InitialiseProfilesTree ¶
InitialiseProfilesTree will initialise all profiles this means that the profile prarent relations are walked and the profile type is determined use this if you need to know the type of every profile in the config for large configuations, this may be expensive
func (*Profiles) LoadInitialisedProfile ¶
LoadInitialisedProfile returns an initialised profile by name this means that all the parents have been loaded and the profile type is defined