Categorygithub.com/joshdk/ykmango
modulepackage
0.0.0-20180821154826-65f49fb7dada
Repository: https://github.com/joshdk/ykmango.git
Documentation: pkg.go.dev

# README

License GoDoc Go Report Card CircleCI CodeCov

YKManGo

šŸ”‘ Prompt a YubiKey device to generate an OATH code

Installing

You can fetch this library by running the following

go get -u github.com/joshdk/ykmango

Additionally, this library has a runtime dependency on ykman which must be installed before use.

Usage

import (
	"fmt"
	"github.com/joshdk/ykmango"
)

// List the currently configured OATH slot names.
names, err := ykman.List()
if err != nil {
	panic(err.Error())
}

for _, name := range names {
	fmt.Printf("Found code named: %s\n", name)
	// Found code named: aws-mfa
}

// Generate an OATH code using the given slot name.
// You may need to touch your YubiKey device if the
// slot is configured to require touch.
code, err := ykman.Generate("aws-mfa")
if err != nil {
	panic(err.Error())
}

fmt.Printf("Your code is: %s\n", code)
// Your code is: 150509

License

This library is distributed under the MIT License, see LICENSE.txt for more information.

# Functions

Generate returns an OATH code from the specified slot name.
List returns all currently configured OATH slot names.

# Variables

ErrorSlotNameUnknown indicates that the specified OATH slot name does not exist.
ErrorYkmanInterrupted indicates that the ykman process was killed with a signal.
ErrorYkmanNotFound indicates that the ykman executable could not be found Installation or $PATH configuration may be needed to correct.
ErrorYubikeyNotDetected indicates that a YubiKey is not currently plugged in.
ErrorYubikeyRemoved indicates that a YubiKey was removed while in-use.
ErrorYubikeyTimeout indicates that a YubiKey was not touched in time to generate an OATH code.