internal

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadMasterPassword

func LoadMasterPassword(opts *Options) ([]byte, error)

LoadMasterPassword loads the master password to encrypt/decrypt the RC file. This function has 3 patterns:

  1. no password
  2. password given through CLI option (`-P`)
  3. password given through terminal (i.e. interactive mode)

func RetrieveSessionToken

func RetrieveSessionToken(otpCode string, accessKeyID string, secretAccessKey string, durationSec int64, mfaSerial string) (*sts.GetSessionTokenOutput, error)

RetrieveSessionToken retrieves session token according to access token and OTP code.

func ShowVersion

func ShowVersion() error

ShowVersion shows the version info.

Types

type Config

type Config struct {
	AccessKeyID     string `json:"accessKeyID"`
	SecretAccessKey string `json:"secretAccessKey"`
	MFASerial       string `json:"mfaSerial"`
	ProfileName     string `json:"profileName"`
}

Config represents the AWS configuration for MFA.

func ReadRCFile

func ReadRCFile(pswd []byte, rcFilePath string) (*Config, error)

ReadRCFile reads the contents of RC file and maps that to the config model.

func (*Config) WriteRCFile

func (c *Config) WriteRCFile(pswd []byte, rcFilePath string) error

WriteRCFile writes the config to a file.

type Options

type Options struct {
	RCFilePath          string                     `short:"r" long:"rc"                       description:"configuration file path of sesstok (default: $HOME/.sesstok.rc)"`
	CredentialsFilePath string                     `short:"c" long:"credentials"              description:"file path of AWS credentials (default: $HOME/.aws/credentials)"`
	PasswordRequired    bool                       `` /* 149-byte string literal not displayed */
	Password            string                     `short:"P"                                 description:"(NOT RECOMMENDED) pass the master password"`
	Duration            int64                      `short:"d" long:"duration" default:"86400" description:"duration of STS session token (unit: second)"`
	TokenOnly           bool                       `short:"t" long:"token-only"               description:"only retrieve STS session token (i.e. don't update credentials file)"`
	Silent              bool                       `short:"s" long:"silent"                   description:"silent mode"`
	Version             bool                       `short:"v" long:"version"                  description:"show the version"`
	DumpRCFile          bool                       `long:"dumprc"                             description:"dump rc file contents"`
	Init                bool                       `` /* 131-byte string literal not displayed */
	Args                struct{ TokenCode string } `positional-args:"yes"`
}

Options represents CLI options.

func (*Options) GetCredentialsFileFullPath

func (o *Options) GetCredentialsFileFullPath() (string, error)

GetCredentialsFileFullPath returns the full path for the AWS credentials file according to the Options model.

func (*Options) GetRCFileFullPath

func (o *Options) GetRCFileFullPath() (string, error)

GetRCFileFullPath returns the full path for RC file according to the Options model.

type OptionsParser

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

OptionsParser represents a parser for CLI options.

func NewOptionsParser

func NewOptionsParser() *OptionsParser

NewOptionsParser returns a new OptionsParser instance.

func (*OptionsParser) ParseArgs

func (p *OptionsParser) ParseArgs(args []string) (*Options, error)

ParseArgs parses the CLI arguments and converts that to the Options.

func (*OptionsParser) Usage

func (p *OptionsParser) Usage()

Usage shows the usage of this application.

Jump to

Keyboard shortcuts

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