Documentation ¶
Index ¶
- Variables
- func LoadAuthyAPI() (*authy.Authy, error)
- type AuthorizedKeysManager
- type Config
- type EachEntryHandler
- type EachUserHandler
- type User
- type UsersManager
- func (manager *UsersManager) AddKey(authyID string, publicKey string) error
- func (manager *UsersManager) AddUser(email string, countryCode int, phoneNumber string, publicKey string) error
- func (manager *UsersManager) AddUserID(authyID string, publicKey string) error
- func (manager *UsersManager) EachEntry(fn EachEntryHandler) error
- func (manager *UsersManager) EachUser(fn EachUserHandler) error
- func (manager *UsersManager) HasUser(userID string) bool
- func (manager *UsersManager) RemoveUser(authyID string) error
- func (manager *UsersManager) UserIDList() []string
- type Verification
Constants ¶
This section is empty.
Variables ¶
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") )
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") )
var ( // DataPath is the default path to read the config from. DataPath = utils.FindUserHome() + "/.authy-onetouch" )
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.
type EachEntryHandler ¶
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 ¶
User is a struct contains the user's info.
func (*User) LoadFromAuthy ¶
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.