ssh

package
v0.0.0-...-d5ede11 Latest Latest
Warning

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

Go to latest
Published: Aug 29, 2018 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUserAlreadyPresent is returned when the user already exists in the db.
	ErrUserAlreadyPresent = errors.New("user is already present")

	// ErrUserDoesNotExist is returned when the user doesn't exist in the db.
	ErrUserDoesNotExist = errors.New("user does not exist")
)
View Source
var (
	// ApprovalTimeout is the time that the user has to approve the request
	ApprovalTimeout = 45 * time.Second

	// MaxAttemptsToReadCode is the times the user is prompted to read the code
	MaxAttemptsToReadCode = 3
	// ErrInvalidVerification is returned when the verification is invalid
	ErrInvalidVerification = errors.New("invalid verification")
)
View Source
var (
	// DataPath is the default path to read the config from.
	DataPath = utils.FindUserHome() + "/.authy-onetouch"
)
View Source
var (
	// Logger is the default logger for this package.
	Logger *log.Logger
)

Functions

func LoadAuthyAPI

func LoadAuthyAPI() (*authy.Authy, error)

LoadAuthyAPI loads a client to connect to the Authy api.

Types

type AuthorizedKeysManager

type AuthorizedKeysManager struct {
}

AuthorizedKeysManager allows to write the authorized_keys file.

func NewAuthorizedKeysManager

func NewAuthorizedKeysManager() *AuthorizedKeysManager

NewAuthorizedKeysManager creates a new writer.

func (*AuthorizedKeysManager) Contains

func (manager *AuthorizedKeysManager) Contains(text string) bool

Contains returns true if the given text is present in the authorized keys file.

func (*AuthorizedKeysManager) Dump

func (manager *AuthorizedKeysManager) Dump()

Dump prints the authorized keys file in the stdout.

func (*AuthorizedKeysManager) Write

func (manager *AuthorizedKeysManager) Write(f io.Writer) error

func (*AuthorizedKeysManager) WriteToDefaultLocation

func (manager *AuthorizedKeysManager) WriteToDefaultLocation() error

WriteToDefaultLocation writes the authorized keys to ~/.ssh/authorized_keys

type Config

type Config struct {
	APIKey    string   `yaml:"api_key"`
	ShellPath string   `yaml:"shell"`
	ShellArgs []string `yaml:"shell_args"`
}

Config contains the configuration of the app.

func LoadConfig

func LoadConfig() (*Config, error)

LoadConfig loads the default config

func NewConfig

func NewConfig(apiKey string) *Config

NewConfig builds a new config object.

func (*Config) Save

func (config *Config) Save() error

Save stores the current config

type EachEntryHandler

type EachEntryHandler func(authyID string, publicKey string)

EachEntryHandler is function prototype for the EachEntry callback

type EachUserHandler

type EachUserHandler func(user *User)

EachUserHandler is function prototype for the EachUser callback

type User

type User struct {
	PublicKeys  []string
	CountryCode int
	PhoneNumber string
	AuthyID     string
}

User is a struct contains the user's info.

func FindUser

func FindUser(userID string) *User

FindUser finds the user in the local database

func (*User) LoadFromAuthy

func (user *User) LoadFromAuthy() error

LoadFromAuthy loads user data from the Authy API

type UsersManager

type UsersManager struct {
}

UsersManager is in charge of adding/deleting/updating/listing users

func NewUsersManager

func NewUsersManager() *UsersManager

NewUsersManager returns the current users manager instance

func (*UsersManager) AddKey

func (manager *UsersManager) AddKey(authyID string, publicKey string) error

AddKey associates a key to the given user id.

func (*UsersManager) AddUser

func (manager *UsersManager) AddUser(email string, countryCode int, phoneNumber string, publicKey string) error

AddUser adds a user to the users db.

func (*UsersManager) AddUserID

func (manager *UsersManager) AddUserID(authyID string, publicKey string) error

AddUserID adds a user id to the users db.

func (*UsersManager) EachEntry

func (manager *UsersManager) EachEntry(fn EachEntryHandler) error

EachEntry goes through every entry in the users db and calls fn with it.

func (*UsersManager) EachUser

func (manager *UsersManager) EachUser(fn EachUserHandler) error

EachUser goes through every user in the users db and calls fn with it.

func (*UsersManager) HasUser

func (manager *UsersManager) HasUser(userID string) bool

HasUser returns true if the user is present in the local db.

func (*UsersManager) RemoveUser

func (manager *UsersManager) RemoveUser(authyID string) error

RemoveUser removes the user with the given `authyID`

func (*UsersManager) UserIDList

func (manager *UsersManager) UserIDList() []string

UserIDList returns the list of user ids present in the users db.

type Verification

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

Verification is an authy verification

func NewVerification

func NewVerification(authyID string) *Verification

NewVerification builds a new verification for the given authy id.

func (*Verification) Run

func (verification *Verification) Run() error

Run starts the verification process

func (*Verification) SendOneTouchRequest

func (verification *Verification) SendOneTouchRequest() (*authy.ApprovalRequest, error)

SendOneTouchRequest sends an approval request to the user.

Jump to

Keyboard shortcuts

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