Documentation
¶
Overview ¶
Package applock is the lock in front of SSHYard's windows: what opens it (a password, a time-based one-time code of an authenticator app, or both), when it locks by itself, and how long wrong attempts make the next one wait.
It keeps the host list and the sessions from whoever sits down at an unlocked computer; it does not encrypt the metadata on disk, which anyone reading the data folder reads anyway. Its file, applock.json, stays on this computer, and no backup takes it. What opens the lock is also a Record in the encrypted local store (keychain.AppLock), which wins over the file once the store is unlocked: deleting or replacing the file does not remove the lock. The password itself is never stored, only a vault-sealed check that opens with it; the one-time code's secret is a secret of the encrypted store too (keychain.AppLockTOTP).
Index ¶
- Constants
- Variables
- func CheckPassword(verifier, password []byte) (bool, error)
- func Code(secret []byte, step int64) string
- func EncodeSecret(secret []byte) string
- func NewSecret() []byte
- func NewVerifier(password []byte, p vault.Params) ([]byte, error)
- func Save(path string, c Config) error
- func Step(t time.Time) int64
- func URI(secret []byte, issuer, account string) string
- func Verify(secret []byte, code string, t time.Time, last int64) (step int64, ok bool)
- type Config
- type Method
Constants ¶
const (
Digits = 6
)
Time-based one-time codes (RFC 6238) as authenticator apps make them by default: HMAC-SHA1, six digits, a new code every 30 seconds.
const File = "applock.json"
File is the name of the lock's file in the data folder.
Variables ¶
var IdleChoices = []int{1, 5, 15, 30, 60, 0}
IdleChoices are the minutes of inactivity the lock may wait before it locks, 0 for never.
var Methods = []Method{Password, TOTP, Both}
Methods are the methods to choose from, in the order they are offered.
Functions ¶
func CheckPassword ¶
CheckPassword reports whether password opens verifier. An error is a verifier that cannot be opened at all.
func EncodeSecret ¶
EncodeSecret is secret as it is typed into an authenticator app.
func NewVerifier ¶
NewVerifier seals the check a password opens, deriving with p.
Types ¶
type Config ¶
type Config struct {
Method Method `json:"method,omitempty"`
// Verifier is a vault sealed with the password, for a method asking
// for it.
Verifier []byte `json:"verifier,omitempty"`
// IdleMinutes of no input in SSHYard lock it; 0 never does.
IdleMinutes int `json:"idleMinutes"`
// LockOnSleep locks as the screen locks or the computer sleeps.
LockOnSleep bool `json:"lockOnSleep"`
// LastStep is the time step of the last one-time code taken, which
// no code may reuse.
LastStep int64 `json:"lastStep,omitempty"`
// Failures is how many attempts in a row failed, RetryAt when the
// next may be made: kept so that quitting does not start them over.
Failures int `json:"failures,omitempty"`
RetryAt time.Time `json:"retryAt,omitzero"`
}
Config is the lock as applock.json keeps it.
func Load ¶
Load reads the lock at path; a missing file is Default. A file that cannot be read is an error, which the caller keeps locked.
func (*Config) Adopt ¶
Adopt makes what the store's record opens with the way c opens, and reports whether c opened another way: the store wins over the file.