Giter VIP home page Giter VIP logo

oath-toolkit-wrapper's Introduction

oath-toolkit-wrapper(a.k.a. mfa)

CI License: MIT

Overview

This is a wrapper command for oath-toolkit. This command allows you to get TOTP from CLI w/o any hassle.

Usage

$ mfa -h
usage: mfa [-h | --help] [-[no]-c | --[no]-copy] [-a <account>| --account <account>] [-l | --list]
  -v, --version                      Prints the version.
  -h, --help                         Prints this message.
  -[no]-c, --[no]-copy               Copies the generated token to the Clipboard.(default)
  -a <account>, --account <account>  Copies the generated token of <account> to the Clipboard.
  -l, --list                         Prints a list of available authenticator accounts.

Demo

Dependencies

To use mfa command, first, the dependencies as follows should be installed:

If the dependencies have not been installed, run the following:

$ brew install jq oath-toolkit [email protected] peco

Installation

Clone this repository:

$ git clone https://github.com/Sean0628/oath-toolkit-wrapper.git ~/.oath-toolkit-wrapper

To use mfa command, edit the $PATH to include paths to the wrapper command.

zsh:

$ echo 'export PATH="$HOME/.oath-toolkit-wrapper/bin:$PATH"' >> ~/.zshrc
$ source ~/.zshrc

bash:

$ echo 'export PATH="$HOME/.oath-toolkit-wrapper/bin:$PATH"' >> ~/.bash_profile
$ source ~/.bash_profile

Configuration

Secret key

Follow the step by step instructions on the link below to extract your secret keys:

Create secret file

  1. Copy and paste your secret keys, and generate your own secrets.json file. cf. Sample format

  2. Encrypt secrets.json with OpenSSL for security purposes. Run the following:

$ openssl enc -aes-256-cbc -a -salt -in secrets.json -out secrets.json.enc

You will be asked for the password. This password will be used when decrypting the secret file also.

  1. Place encrypted secrets.json into config/ directory:
$ mv secrets.json.enc ~/.oath-toolkit-wrapper/config
  1. Remove redundant secrets.json file:
$ rm secrets.json

[Optional]Password

It is possible to omit entering password each time you use mfa command by creating config/credentials.json.

Create credential file

  1. Generate your own credentials.json file. cf. Sample format

This password should be the same password which is used to encrypt secrets.json file.

  1. Place credentials.json into config/ directory:
$ mv credentials.json ~/.oath-toolkit-wrapper/config
  1. Set permission and change the owner for security purposes:
$ chmod 400 config/credentials.json
$ sudo chown root config/credentials.json

Copyright

Copyright (c) 2020 Sho ITO. See LICENSE.md for further details.

oath-toolkit-wrapper's People

Contributors

sean0628 avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

oath-toolkit-wrapper's Issues

Testing basic use cases

TEST

  • w/o options(default)
    • is possible to select an account w/ peco
    • generates TOTP token, and prints out a message w/ the token
    • Copies the generated token to the Clipboard
    • tmp/secrets.json has been deleted
    • password input
      • credentials file is present
        • password key is present
          • reads from the credentials file
          • tmp/secrets.json has been deleted
        • password key is not present
          • reads from STDIN, Enter encryption password:
          • tmp/secrets.json has been deleted
      • credentials file is not present
        • correct password
          • reads from STDIN, Enter encryption password:
          • tmp/secrets.json has been deleted
        • wrong password
          • reads from STDIN, Enter encryption password:
          • ends w/ error message
            • openssl decryption has faliled. Maybe wrong password?
      • encrypted secrets file existance
        • is not present
          • ends w/ error message
            • "Cannot find encrypted secrets file. Please generate secrets file with the command below.\n"
            • "$ openssl enc -aes-256-cbc -a -salt -in <SECRETS_FILE> -out $ENCRYPTED_SECRETS_FILE\n"
          • tmp/secrets.json has been deleted
        • is present
          • is possible to select an account w/ peco
          • generates TOTP token, and prints out a message w/ the token
          • Copies the generated token to the Clipboard
          • tmp/secrets.json has been deleted
      • errors
        • terminates w/ Ctrl+c
          • ends the process w/ status 1
          • tmp/secrets.json has been deleted
        • dependencies
          • openssl
            • present
              • is possible to select an account w/ peco
              • generates TOTP token, and prints out a message w/ the token
              • Copies the generated token to the Clipboard
              • tmp/secrets.json has been deleted
            • not present
              • ends w/ error message
              • tmp/secrets.json has been deleted
          • jq
            • present
              • is possible to select an account w/ peco
              • generates TOTP token, and prints out a message w/ the token
              • Copies the generated token to the Clipboard
              • tmp/secrets.json has been deleted
            • not present
              • ends w/ error message
              • tmp/secrets.json has been deleted
          • peco
            • present

              • is possible to select an account w/ peco
              • generates TOTP token, and prints out a message w/ the token
              • Copies the generated token to the Clipboard
              • tmp/secrets.json has been deleted
            • not present

              • ends w/ error message
              • tmp/secrets.json has been deleted
          • oathtool
            • present
              • is possible to select an account w/ peco
              • generates TOTP token, and prints out a message w/ the token
              • Copies the generated token to the Clipboard
              • tmp/secrets.json has been deleted
            • not present
              • ends w/ error message
              • tmp/secrets.json has been deleted
    • w/ options
      • invalid options
        • ends w/ error message
        • tmp/secrets.json has been deleted
      • -v, --version
        • -v
          • prints the version
          • tmp/secrets.json has been deleted
        • --version
          • prints the version
          • tmp/secrets.json has been deleted
      • -h, --help
        • -h
          • prints the help message
          • tmp/secrets.json has been deleted
        • --help
          • prints the help message
          • tmp/secrets.json has been deleted
      • -[no]-c, --[no]-copy
        • -c
          • is possible to select an account w/ peco
          • generates TOTP token, and prints out a message w/ the token
          • Copies the generated token to the Clipboard
          • tmp/secrets.json has been deleted
        • --copy
          • is possible to select an account w/ peco
          • generates TOTP token, and prints out a message w/ the token
          • Copies the generated token to the Clipboard
          • tmp/secrets.json has been deleted
        • -no-c
          • is possible to select an account w/ peco
          • generates TOTP token, and prints out a message w/ the token
          • does not copy the generated token to the Clipboard
          • tmp/secrets.json has been deleted
        • --no-copy
          • is possible to select an account w/ peco
          • generates TOTP token, and prints out a message w/ the token
          • does not copy the generated token to the Clipboard
          • tmp/secrets.json has been deleted
      • -a , --account
        • account is specified
          • account is valid
            • -a
              • generates TOTP token, and prints out a message w/ the token
              • copies the generated token of to the Clipboard
              • tmp/secrets.json has been deleted
            • --account
              • generates TOTP token, and prints out a message w/ the token
              • copies the generated token of to the Clipboard
              • tmp/secrets.json has been deleted
        • account is invalid
          • ends the process w/ message
            • "mfa: ${opt} is not a valid command. See mfa -h for more details."
          • tmp/secrets.json has been deleted
        • account is not specified
          • -a
            • is possible to select an account w/ peco
            • generates TOTP token, and prints out a message w/ the token
            • does not copy the generated token to the Clipboard
            • tmp/secrets.json has been deleted
          • --account
            • is possible to select an account w/ peco
            • generates TOTP token, and prints out a message w/ the token
            • does not copy the generated token to the Clipboard
            • tmp/secrets.json has been deleted
      • -l, --list
        • -l
          • prints a list of available authenticator accounts
          • tmp/secrets.json has been deleted
        • --lsit
          • prints a list of available authenticator accounts
          • tmp/secrets.json has been deleted

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.