Skip to content

Commit

Permalink
doc: update README
Browse files Browse the repository at this point in the history
  • Loading branch information
petlack committed Jul 12, 2024
1 parent 75b4330 commit f55959f
Showing 1 changed file with 65 additions and 55 deletions.
120 changes: 65 additions & 55 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[![Tests](https://github.com/petlack/dotp/actions/workflows/tests.yml/badge.svg)](https://github.com/petlack/dotp/actions/workflows/tests.yml)
[![Compile Binaries](https://github.com/petlack/dotp/actions/workflows/compile.yml/badge.svg)](https://github.com/petlack/dotp/actions/workflows/compile.yml)
[![Build Alpine Linux Package](https://github.com/petlack/dotp/actions/workflows/alpine.yml/badge.svg)](https://github.com/petlack/dotp/actions/workflows/alpine.yml)
[![Build Arch Linux Package](https://github.com/petlack/dotp/actions/workflows/archlinux.yml/badge.svg)](https://github.com/petlack/dotp/actions/workflows/archlinux.yml)
[![Build Debian Package](https://github.com/petlack/dotp/actions/workflows/debian.yml/badge.svg)](https://github.com/petlack/dotp/actions/workflows/debian.yml)
[![Compile Binaries](https://github.com/petlack/dotp/actions/workflows/compile.yml/badge.svg)](https://github.com/petlack/dotp/actions/workflows/compile.yml)
[![Tests](https://github.com/petlack/dotp/actions/workflows/tests.yml/badge.svg)](https://github.com/petlack/dotp/actions/workflows/tests.yml)

# dotp

Expand All @@ -16,7 +16,14 @@
- [Get current TOTP code](#get-current-totp-code)
- [Validate TOTP code](#validate-totp-code)
- [`secret_options`](#secretoptions)
- [Examples](#examples)
- [Secret stored in environment variable](#secret-stored-in-environment-variable)
- [Secret stored in file](#secret-stored-in-file)
- [Using Unsafe Secret Value](#using-unsafe-secret-value)
- [Usage with `pass`](#usage-with-pass)
- [Integration with `qrencode`](#integration-with-qrencode)
- [Installation](#installation)
- [Alpine](#alpine)
- [Archlinux](#archlinux)
- [Install from AUR](#install-from-aur)
- [Build package from source](#build-package-from-source)
Expand All @@ -25,12 +32,6 @@
- [Other](#other)
- [Build from source](#build-from-source)
- [Install release binary](#install-release-binary)
- [Examples](#examples)
- [Secret stored in environment variable](#secret-stored-in-environment-variable)
- [Secret stored in file](#secret-stored-in-file)
- [Using Unsafe Secret Value](#using-unsafe-secret-value)
- [Usage with `pass`](#usage-with-pass)
- [Integration with `qrencode`](#integration-with-qrencode)
<!--toc:end-->

## Usage
Expand Down Expand Up @@ -62,8 +63,64 @@ These options describe the source of the secret and can be one of
| `--secret-stdin` | Read secret from stdin |
| `--secret-unsafe-value mysecret` | Use the secret provided as an argument |

## Examples

### Secret stored in environment variable
Set an environment variable `TOTP_SECRET` and use it to get the TOTP code:
```bash
export TOTP_SECRET="mysecret"
dotp get --secret-env TOTP_SECRET
```

### Secret stored in file
Store your secret in a file and retrieve the TOTP code:
```bash
echo "mysecret" > ./secret.plaintext
dotp get --secret-file ./secret.plaintext
```

### Using Unsafe Secret Value
Directly provide the secret as an argument (not recommended for production use):
```bash
dotp get --secret-unsafe-value "mysecret"
```

### Usage with `pass`

To generate a new secret key and store it in password store, run
```bash
dotp new | pass insert -e "TOTP/foo"
```

To get a current TOTP code, run
```bash
pass show "TOTP/foo" | dotp get --secret-stdin
```

To validate a TOTP code, run
```bash
pass show "TOTP/foo" | dotp validate --secret-stdin "000111"
```

### Integration with `qrencode`
To add the TOTP secret to a mobile app, you can use [qrencode](https://github.com/fukuchi/libqrencode) to generate and display the QR code.
```bash
pass show 'TOTP/mykey' |
dotp uri --account foo@bar --issuer myapp --secret-stdin |
qrencode -t ANSI
```

## Installation

### Alpine
Head to the [Releases](https://github.com/petlack/dotp/releases) section and download the latest apk package and public key.
```bash
wget https://github.com/petlack/dotp/releases/download/v0.0.1.20240712.02/dotp-0.0.1.20240712.02-r1.apk
wget https://github.com/petlack/dotp/releases/download/v0.0.1.20240712.02/dotp-0.0.1.20240712.02-r1.apk.rsa.pub
cp dotp-0.0.1.20240712.02-r1.apk.rsa.pub /etc/apk/keys/
apk add dotp-0.0.1.20240712.02-r1.apk
```

### Archlinux
#### Install from AUR
```bash
Expand Down Expand Up @@ -109,50 +166,3 @@ Example:
wget https://github.com/petlack/dotp/releases/download/v0.0.1.20240712.02/dotp-linux-amd64
install -m 755 dotp-linux-amd64 /usr/local/bin/dotp
```

## Examples

### Secret stored in environment variable
Set an environment variable `TOTP_SECRET` and use it to get the TOTP code:
```bash
export TOTP_SECRET="mysecret"
dotp get --secret-env TOTP_SECRET
```

### Secret stored in file
Store your secret in a file and retrieve the TOTP code:
```bash
echo "mysecret" > ./secret.plaintext
dotp get --secret-file ./secret.plaintext
```

### Using Unsafe Secret Value
Directly provide the secret as an argument (not recommended for production use):
```bash
dotp get --secret-unsafe-value "mysecret"
```

### Usage with `pass`

To generate a new secret key and store it in password store, run
```bash
dotp new | pass insert -e "TOTP/foo"
```

To get a current TOTP code, run
```bash
pass show "TOTP/foo" | dotp get --secret-stdin
```

To validate a TOTP code, run
```bash
pass show "TOTP/foo" | dotp validate --secret-stdin "000111"
```

### Integration with `qrencode`
To add the TOTP secret to a mobile app, you can use [qrencode](https://github.com/fukuchi/libqrencode) to generate and display the QR code.
```bash
pass show 'TOTP/mykey' |
dotp uri --account foo@bar --issuer myapp --secret-stdin |
qrencode -t ANSI
```

0 comments on commit f55959f

Please sign in to comment.