summaryrefslogtreecommitdiffstats
path: root/README.md
blob: 70a87ca81c16462b709dd356da65f9d0f5fdb1c4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# cloak

A Command Line OTP (One Time Password) Authenticator application written in Rust that generates
time-based and counter-based OTP codes.

![CI](https://github.com/evansmurithi/cloak/workflows/CI/badge.svg)
[![codecov](https://codecov.io/gh/evansmurithi/cloak/branch/master/graph/badge.svg?token=Y72C1MM1E8)](https://codecov.io/gh/evansmurithi/cloak)
![License](https://img.shields.io/crates/l/cloak.svg)
[![Crates.io version](https://img.shields.io/crates/v/cloak.svg)](https://crates.io/crates/cloak)

## Motivation

- [Why you shouldn’t scan two-factor authentication QR codes!](https://medium.com/crypto-punks/why-you-shouldnt-scan-two-factor-authentication-qr-codes-e2a44876a524)
- As a means of learning the Rust programming language.
- Easier to copy the OTP code from my terminal to the login form, rather than from
my phone to my laptop.

## Example

<p align="center">
    <img src="https://cdn.rawgit.com/evansmurithi/cloak/6d113aa8376b04cce12b64261962750532997e64/assets/cloak_example.svg">
</p>

## Installation

To install `cloak`, you can do either of the following:

1. **Binaries**

    You can download the binaries [here](https://github.com/evansmurithi/cloak/releases).
    Make sure to put the path to the binary into your `PATH`.

    Alternatively, you can install `cloak` via the [scoop package manager](https://scoop.sh) with the following command:

    ```powershell
    scoop install cloak
    ```

2. **Crates.io**

    Once you've installed Rust, install `cloak` by typing the following in the terminal:

    ```bash
    cargo install cloak
    ```

    This will download and compile `cloak`. After this is finished, add the Cargo
    bin directory to your `PATH`.

## Usage

The sub-commands included in `cloak` are as follows:

```bash
$ cloak -h
cloak 0.1.0
Evans Murithi <murithievans80@gmail.com>
A Command Line OTP Authenticator application.

USAGE:
    cloak [SUBCOMMAND]

FLAGS:
    -h, --help       Prints help information
    -V, --version    Prints version information

SUBCOMMANDS:
    add               Add a new account
    delete            Delete an account
    help              Prints this message or the help of the given subcommand(s)
    list              List OTP for all accounts
    view              View the OTP for an account
```

To view the help of any of the subcommands below, add `-h` or `--help`, e.g. `cloak add -h`.

- `cloak add <account> <key>`

    This will add a new account. You will need to provide the name of the account
    as well as valid base32 encoded key. Example:

    ```bash
    $ cloak add github 4AZJFQFIGYM2KMTOO72I6FAOZ6ZFWJR6
    ```

- `cloak view <account>`

    This will print the TOTP/HOTP of the account you want to view. Example:

    ```bash
    $ cloak view github
    123456
    ```

- `cloak list`

    This prints all the accounts with their respective TOTP/HOTP codes. Example:

    ```bash
    $ cloak list
    Account: github
    TOTP: 607091

    Account: gitlab
    TOTP: 325414
    ```

- `cloak delete <account>`

    This will delete an account. Once deleted, you cannot view the OTP codes for
    the account. Example:

    ```bash
    $ cloak delete github
    Account successfully deleted
    $ cloak view github
    Account with the name 'github' does not exist. Consider adding it.
    ```

## Customization

By default `cloak` stores your accounts and recovery codes inside a `.cloak/`
directory found inside your `$HOME` folder if you are on Linux or macOS, or
inside your user profile folder if you are on Windows.

To alter this, you can use the `CLOAK_ACCOUNTS_DIR` environment variable to
point `cloak` to the directory to use for storing your accounts and recovery
codes:

```bash
export CLOAK_ACCOUNTS_DIR='/save/accounts/here/'  # absolute path
```

## Contributions

If you want to contribute to `cloak` you will have to clone the repository on your
local machine:

```bash
$ git clone https://github.com/evansmurithi/cloak.git
```

To build, `cd` into `cloak/` and run:

```bash
$ cargo build
```

To run tests:

```bash
$ cargo test
```