-
Notifications
You must be signed in to change notification settings - Fork 821
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #558 from 99designs/ykman-support
Yubikey support
- Loading branch information
Showing
8 changed files
with
88 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package prompt | ||
|
||
import ( | ||
"fmt" | ||
"log" | ||
"os" | ||
"os/exec" | ||
"strings" | ||
) | ||
|
||
// YkmanProvider runs ykman to generate a OATH-TOTP token from the Yubikey device | ||
// To set up ykman, first run `ykman oath add` | ||
func YkmanProvider(mfaSerial string) (string, error) { | ||
yubikeyOathCredName := os.Getenv("YKMAN_OATH_CREDENTIAL_NAME") | ||
if yubikeyOathCredName == "" { | ||
yubikeyOathCredName = mfaSerial | ||
} | ||
|
||
log.Printf("Fetching MFA code using `ykman oath code --single %s`", yubikeyOathCredName) | ||
cmd := exec.Command("ykman", "oath", "code", "--single", yubikeyOathCredName) | ||
cmd.Stderr = os.Stderr | ||
|
||
out, err := cmd.Output() | ||
if err != nil { | ||
return "", fmt.Errorf("ykman: %w", err) | ||
} | ||
|
||
return strings.TrimSpace(string(out)), nil | ||
} | ||
|
||
func init() { | ||
Methods["ykman"] = YkmanProvider | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters