Documentation
¶
Index ¶
- Constants
- Variables
- func ConfigContext(ctx context.Context, config *Config) context.Context
- func Execute(ctx context.Context, args []string) error
- func FindOktaHeaders(r *http.Response) []slog.Attr
- func GetExitCode(err error) (int, bool)
- func ResolveAWSCredentialsPath(rootPath string) string
- func SaveCloudCredentialInCLI(cloudCliPath string, entry CloudCliEntry) error
- func ShouldUseMachineOutput(flags flagSet) bool
- func TouchFile(path string) (*os.File, error)
- func UnknownAccountError(accountID, bypassCacheFlag string) error
- func UnknownRoleError(role, applicationID string) error
- type AWSError
- type Account
- type CloudCliEntry
- type CloudCredentials
- type Config
- func (c *Config) AddAccount(id string, account Account)
- func (c *Config) Alias(id, name string)
- func (c *Config) Decode(reader io.Reader) error
- func (c *Config) DumpAccounts(w io.Writer, withHeaders bool)
- func (c *Config) Encode(w io.Writer) error
- func (c *Config) FindAccount(name string) (Account, bool)
- func (c *Config) Unalias(name string)
- func (c *Config) UpdateAccounts(entries []Account)
- type ErrKeychainLocked
- type ErrNoPortsAvailable
- type GetCommand
- type LogRoundTripper
- type LoginCommand
- type OktaError
- type ShellType
- type SwitchCommand
- type TimeToLiveError
- type UsageError
- type ValueError
Constants ¶
const ( // DefaultTTL for requested credentials in hours DefaultTTL uint = 1 // DefaultTimeRemaining for new key requests in minutes DefaultTimeRemaining uint = 5 )
const ( ExitCodeTokensExpiredOrAbsent int = 0x1 ExitCodeUndisclosedOktaError int = 0x2 ExitCodeAuthenticationError int = 0x3 ExitCodeConnectivityError int = 0x4 ExitCodeValueError int = 0x5 ExitCodeAWSError int = 0x6 ExitCodeUnknownError int = 0x7D )
const CredentialProcessVersion = 1
CredentialProcessVersion is the schema version required by the AWS SDKs' credential_process protocol. It must always be 1. See https://docs.aws.amazon.com/sdkref/latest/guide/feature-process-credentials.html
Variables ¶
var ( FlagNoRefresh = "no-refresh" FlagServerAddress = "server-address" ErrSessionExpired = errors.New("session expired") )
var ( ClientID string OIDCDomain string ServerAddress string Version = "TBD" BuildTimestamp = "BuildTimestamp is not set" // CallbackPorts is a list of ports that will be attempted in no particular order for hosting an Oauth2 callback web server. // This cannot be set using -ldflags='-X ..' because -X requires that this be a string literal or uninitialized. // // These ports are chosen somewhat arbitrarily CallbackPorts = []string{"57468", "47512", "57123", "61232", "48231", "49757", "59834", "54293"} )
Vars for build time
var ( FlagRegion = "region" FlagRoleName = "role" FlagTimeRemaining = "time-remaining" FlagTimeToLive = "ttl" FlagBypassCache = "bypass-cache" FlagLogin = "login" FlagProfileName = "profile" )
var ( FlagURLOnly = "url-only" FlagNoBrowser = "no-browser" )
var ( FlagOIDCDomain = "oidc-domain" FlagClientID = "client-id" FlagQuiet = "quiet" FlagTimeout = "timeout" )
var ( FlagRoleSessionName = "role-session-name" FlagOutputType = "output" FlagShellType = "shell" FlagAWSCLIPath = "awscli" )
var ( ErrTokensExpiredOrAbsent = UsageError{ ExitCode: ExitCodeTokensExpiredOrAbsent, DebugMessage: "tokens expired or absent", Description: "Your session has expired. Please login again.", } )
Functions ¶
func GetExitCode ¶
func SaveCloudCredentialInCLI ¶
func SaveCloudCredentialInCLI(cloudCliPath string, entry CloudCliEntry) error
func ShouldUseMachineOutput ¶
func ShouldUseMachineOutput(flags flagSet) bool
ShouldUseMachineOutput indicates whether or not we should write to standard output as if the user is a machine.
What this means is implementation specific, but this usually indicates the user is trying to use this program in a script and we should avoid user-friendly output messages associated with values a user might find useful.
func UnknownAccountError ¶
func UnknownRoleError ¶
Types ¶
type Account ¶
type Account struct {
ID string `json:"id"`
Name string `json:"name"`
Alias string `json:"alias"`
MostRecentRole string `json:"most_recent_role"`
}
func (*Account) IsNameMatch ¶
func (*Account) NormalizeName ¶
type CloudCliEntry ¶
type CloudCliEntry struct {
// contains filtered or unexported fields
}
func NewCloudCliEntry ¶
func NewCloudCliEntry(c CloudCredentials, a Account, profileName string) CloudCliEntry
type CloudCredentials ¶
type CloudCredentials struct {
Version int `json:"Version"`
AccountID string `json:"AccountId"`
AccessKeyID string `json:"AccessKeyId"`
SecretAccessKey string `json:"SecretAccessKey"`
SessionToken string `json:"SessionToken"`
Expiration string `json:"Expiration"`
}
func LoadAWSCredentialsFromEnvironment ¶
func LoadAWSCredentialsFromEnvironment() CloudCredentials
func (*CloudCredentials) ValidUntil ¶
func (c *CloudCredentials) ValidUntil(account Account, dur time.Duration) bool
func (CloudCredentials) WriteFormat ¶
type Config ¶
type Config struct {
Accounts *accountSet `json:"accounts"`
TTL uint `json:"ttl"`
TimeRemaining uint `json:"time_remaining"`
LastUsedAccount *string `json:"last_used_account"`
}
Config stores all information related to the user
func ConfigFromContext ¶
func (*Config) AddAccount ¶
func (*Config) Decode ¶
Decode populates all member values of config using default values where needed
func (*Config) Encode ¶
Encode writes the config to the file provided overwriting the file if it exists
func (*Config) UpdateAccounts ¶
type ErrKeychainLocked ¶
type ErrKeychainLocked struct{}
ErrKeychainLocked indicates that the operating system keychain is locked and needs to be unlocked.
This usually only occurs on Darwin systems.
func (ErrKeychainLocked) Error ¶
func (e ErrKeychainLocked) Error() string
func (ErrKeychainLocked) ExitCode ¶
func (e ErrKeychainLocked) ExitCode() int
type ErrNoPortsAvailable ¶
type ErrNoPortsAvailable struct{}
func (ErrNoPortsAvailable) Error ¶
func (e ErrNoPortsAvailable) Error() string
func (ErrNoPortsAvailable) ExitCode ¶
func (e ErrNoPortsAvailable) ExitCode() int
type GetCommand ¶
type GetCommand struct {
AccountIDOrName string
TimeToLive uint
TimeRemaining uint
OutputType, ShellType, RoleName, AWSCLIPath, OIDCDomain, ClientID, Region, ProfileName string
Login, URLOnly, NoBrowser, BypassCache, MachineOutput bool
}
func (*GetCommand) Parse ¶
func (g *GetCommand) Parse(flags flagSet) error
type LogRoundTripper ¶
type LogRoundTripper struct {
RoundTripper http.RoundTripper
}
type LoginCommand ¶
func (LoginCommand) Execute ¶
func (c LoginCommand) Execute(ctx context.Context, config *Config) error
func (*LoginCommand) Parse ¶
func (c *LoginCommand) Parse(flags flagSet, args []string) error
type SwitchCommand ¶
type SwitchCommand struct {
OutputType string
ShellType string
AWSCLIPath string
RoleSessionName string
AccountID string
}
func (*SwitchCommand) Parse ¶
func (s *SwitchCommand) Parse(flags flagSet) error
type TimeToLiveError ¶
func (TimeToLiveError) Code ¶
func (o TimeToLiveError) Code() int
func (TimeToLiveError) Error ¶
func (o TimeToLiveError) Error() string
type UsageError ¶
UsageError indicates that the user used the program incorrectly
func (UsageError) Code ¶
func (u UsageError) Code() int
func (UsageError) Error ¶
func (u UsageError) Error() string
type ValueError ¶
func (ValueError) Code ¶
func (v ValueError) Code() int
func (ValueError) Error ¶
func (v ValueError) Error() string