Documentation ¶
Index ¶
- Constants
- func Run(c cmd) (interface{}, error)
- func RunAndPrint(c printCmd) error
- type Account
- type AccountSpec
- type Accounts
- func (s Accounts) ClearErr() Accounts
- func (s Accounts) CredsOrErr() Accounts
- func (s Accounts) CtlOrErr() Accounts
- func (s Accounts) EnsureCreds(d time.Duration) Accounts
- func (s Accounts) Filter(fn func(ac *Account) bool) Accounts
- func (s Accounts) InitCtl() Accounts
- func (s Accounts) LoadCtl(reload bool) Accounts
- func (s Accounts) Map(fn func(i int, ac *Account) error) Accounts
- func (s Accounts) SortByID() Accounts
- func (s Accounts) SortByName() Accounts
- func (s Accounts) StoreCtl() Accounts
- type AuthMode
- type Ctl
- type Ctx
- func (c *Ctx) Accounts() Accounts
- func (c *Ctx) AuthMode() AuthMode
- func (c *Ctx) Cfg() aws.Config
- func (c *Ctx) CredsProvider(accountID string) *creds.Provider
- func (c *Ctx) Ident() creds.Ident
- func (c *Ctx) Init(cfg *aws.Config) error
- func (c *Ctx) MasterExternalID() *string
- func (c *Ctx) Match(spec string) (Accounts, error)
- func (c *Ctx) Okta() *okta.Client
- func (c *Ctx) Org() account.Org
- func (c *Ctx) Refresh() error
- func (c *Ctx) Register(acs Accounts) Accounts
- func (c *Ctx) Role() arn.ARN
- func (c *Ctx) Save() *SavedCtx
- type Error
- type Flags
- type GetCtx
- type SavedCtx
- type Tags
- type Ver
Constants ¶
const ( // ErrNoAccess indicates missing or invalid account credentials. ErrNoAccess = Error("account access denied") // ErrNoCtl indicates missing account control information. ErrNoCtl = Error("account control not initialized") // ErrCtlUpdate indicates that account control information was not saved. ErrCtlUpdate = Error("account control update interrupted") )
const ( IAMPath = "/oktapus/" IAMTmpPath = IAMPath + "tmp/" )
Paths for managed IAM users and roles.
const ( DaemonEnv = "OKTAPUS_DAEMON" SecretFileEnv = "OKTAPUS_SECRET_FILE" AliasFileEnv = "OKTAPUS_ALIAS_FILE" ProfileEnv = "OKTAPUS_AWS_PROFILE" MasterRoleEnv = "OKTAPUS_MASTER_ROLE" CommonRoleEnv = "OKTAPUS_COMMON_ROLE" OktaHostEnv = "OKTA_ORG" OktaUserEnv = "OKTA_USERNAME" OktaAWSAppEnv = "OKTA_AWS_APP_URL" OktaAWSRoleEnv = "OKTA_AWS_ROLE_TO_ASSUME" )
Oktapus environment variables. Okta variables use same names as: https://github.com/oktadeveloper/okta-aws-cli-assume-role/
const CtlRole = "OktapusAccountControl"
CtlRole is the IAM role that stores account control information in its description.
const CtxVer = Ver(1)
CtxVer identifies Ctx and SavedCtx struct versions. It should be incremented for any incompatible changes to force the daemon to restart.
Variables ¶
This section is empty.
Functions ¶
func Run ¶
func Run(c cmd) (interface{}, error)
Run executes the specified command with a local context.
func RunAndPrint ¶
func RunAndPrint(c printCmd) error
RunAndPrint executes the specified command with a local context and prints its output.
Types ¶
type Account ¶
type Account struct { Flags ID string Name string IAM iamx.Client Ctl Ctl Err error // contains filtered or unexported fields }
Account maintains control information and provides IAM access for one AWS account.
func NewAccount ¶
NewAccount returns a new account with the given id and name.
func (*Account) CredsProvider ¶
CredsProvider returns the credentials provider for account ac.
type AccountSpec ¶
type AccountSpec struct {
// contains filtered or unexported fields
}
AccountSpec specifies how to filter accounts.
func ParseAccountSpec ¶
func ParseAccountSpec(spec, user string) *AccountSpec
ParseAccountSpec parses the account spec string. User argument determines the meaning of "owner=me" specification.
func (*AccountSpec) Filter ¶
func (s *AccountSpec) Filter(acs Accounts) (Accounts, error)
Filter returns only those accounts that match the spec.
func (*AccountSpec) IsStatic ¶
func (s *AccountSpec) IsStatic(acs Accounts) bool
IsStatic returns true if the spec uses account IDs and/or names.
type Accounts ¶
type Accounts []*Account
Accounts is a group of accounts that can be operated on concurrently.
func (Accounts) CredsOrErr ¶
CredsOrErr sets the Err field of all accounts without valid credentials or an an existing error.
func (Accounts) CtlOrErr ¶
CtlOrErr sets the Err field of all accounts without control information or an existing error.
func (Accounts) EnsureCreds ¶
EnsureCreds ensures that credentials of all accounts will remain valid for the specified duration, renewing them if necessary.
func (Accounts) Filter ¶
Filter returns a new slice containing only those accounts for which fn evaluates to true.
func (Accounts) LoadCtl ¶
LoadCtl loads control information for accounts without LoadFlag set. If reload is true, the flag is ignored.
func (Accounts) Map ¶
Map concurrently executes fn for each account. Any error returned by fn is stored in the associated account.
func (Accounts) SortByName ¶
SortByName sorts accounts by name.
type Ctl ¶
type Ctl struct { Owner string `json:"owner,omitempty"` Desc string `json:"desc,omitempty"` Tags Tags `json:"tags,omitempty"` }
Ctl contains account control information.
type Ctx ¶
type Ctx struct { // Oktapus environment config Daemon daemon.Addr `env:"OKTAPUS_DAEMON"` SecretFile string `env:"OKTAPUS_SECRET_FILE"` AliasFile string `env:"OKTAPUS_ALIAS_FILE"` Profile string `env:"OKTAPUS_AWS_PROFILE"` MasterRole string `env:"OKTAPUS_MASTER_ROLE"` CommonRole string `env:"OKTAPUS_COMMON_ROLE"` // Okta environment config OktaHost string `env:"OKTA_ORG"` OktaUser string `env:"OKTA_USERNAME"` OktaAWSApp string `env:"OKTA_AWS_APP_URL"` OktaAWSRole string `env:"OKTA_AWS_ROLE_TO_ASSUME"` // AWS environment config EnvCfg external.EnvConfig // contains filtered or unexported fields }
Ctx provides global config information and account access. A context can be local or non-local. Local contexts are allowed to access the file system, refresh accounts, communicate with the daemon, and perform other client functions. Non-local contexts, maintained by the daemon, are only allowed to make API calls to keep account credentials and control information current.
func EnvCtx ¶
func EnvCtx() *Ctx
EnvCtx returns a local context populated from the environment variables.
func (*Ctx) CredsProvider ¶
CredsProvider returns a credentials provider for the specified account ID.
func (*Ctx) Init ¶
Init initializes a local context before first use. If cfg is nil, client config is loaded from context state and shared AWS config files.
func (*Ctx) MasterExternalID ¶
MasterExternalID derives the external id for the master role.
func (*Ctx) Refresh ¶
Refresh updates the list of known accounts from the alias file and/or AWS Organizations API.
type Flags ¶
type Flags uint32
Flags contains account state flags.
const ( CredsFlag Flags = 1 << iota // Credentials are valid LoadFlag // Control information load was attempted CtlFlag // Control information is valid OrgFlag // Account belongs to an organization )
Flag bits.
func (Flags) CredsValid ¶
CredsValid returns true if the account credentials are valid.
type GetCtx ¶
GetCtx is a daemon message requesting the context with the specified signature. The daemon either sends the matching *SavedCtx or closes the connection if the context was not found.
type SavedCtx ¶
type SavedCtx struct { Ver Ctx Ctx Sig string Secret string OktaSess *okta.Session OktaCreds *aws.Credentials // TODO: Save creds in other modes? ProxyIdent creds.Ident ProxySessName string DirOrg account.Org Creds []savedCreds Accounts []Account }
SavedCtx is a serializable context representation.
type Tags ¶
type Tags []string
Tags is a collection of keywords associated with an account. All methods assume that tags are sorted, each tag is unique, and no tag is negated.
func (*Tags) Apply ¶
Apply updates t by adding tags in set and removing those in clr. Setting tags takes priority over clearing them if the sets are not disjoint.
func (Tags) Diff ¶
Diff returns tags that are set and/or cleared in t relative to u. Calling u.Apply(set, clr) would make u == t.