|
| 1 | +# Credential handling |
| 2 | + |
| 3 | +By default, login credentials are stored securely using the secure store provided by your platform, e.g. on Linux it would use the [D-Bus secrets service](https://specifications.freedesktop.org/secret-service/latest/). |
| 4 | + |
| 5 | +## Credential helpers |
| 6 | + |
| 7 | +It is also possible to override the keychain storage and use a custom credential helper instead. |
| 8 | + |
| 9 | +A credential helper is a program, which is called by `enarx` with two positional arguments a `mode` as the first and an `oidc_domain` as the second like so: `<credential helper> <insert|show> <oidc_domain>`. |
| 10 | + |
| 11 | +### `insert` mode |
| 12 | + |
| 13 | +When called with `"insert"` in the first argument, credential helper should read and securely store the secret associated with `oidc_domain` passed in the second argument from stdin. |
| 14 | + |
| 15 | +Example invocation: |
| 16 | + |
| 17 | +```sh |
| 18 | +enarx-credential-helper-mybackend insert auth.profian.com |
| 19 | +``` |
| 20 | + |
| 21 | +### `show` mode |
| 22 | + |
| 23 | +When called with `"show"` in the first argument, credential helper should write the secret associated with `oidc_domain` passed in the second argument to stdout. |
| 24 | + |
| 25 | +Example invocation: |
| 26 | + |
| 27 | +```sh |
| 28 | +enarx-credential-helper-mybackend show auth.profian.com |
| 29 | +``` |
| 30 | + |
| 31 | +### Configuration |
| 32 | + |
| 33 | +In order to use a credential helper, either set `ENARX_CREDENTIAL_HELPER` environment variable equal to absolute path to an executable credential helper or pass it via `credential-helper` command-line flag. |
| 34 | + |
| 35 | +Example invocation: |
| 36 | +```sh |
| 37 | +enarx user login --credential-helper /usr/bin/enarx-credential-helper-gopass |
| 38 | +``` |
| 39 | + |
| 40 | +Alternatively: |
| 41 | +```sh |
| 42 | +ENARX_CREDENTIAL_HELPER=/usr/bin/enarx-credential-helper-gopass enarx user login |
| 43 | +``` |
| 44 | + |
| 45 | +Eventually, it will be possible to configure credential helpers via a CLI configuration file. Please follow https://github.com/enarx/enarx/issues/2021 for more details. |
| 46 | + |
| 47 | +### Example credential helpers |
| 48 | + |
| 49 | +#### Pass |
| 50 | + |
| 51 | +The following credential helper can be used to store credentials in [`pass`](https://www.passwordstore.org/): |
| 52 | + |
| 53 | +```sh |
| 54 | +#!/bin/sh |
| 55 | +set -e |
| 56 | +if [ "${1}" = "insert" ]; then |
| 57 | + exec pass insert -f -m "misc/enarx/${2}" 1> /dev/null |
| 58 | +elif [ "${1}" = "show" ]; then |
| 59 | + exec pass show "misc/enarx/${2}" |
| 60 | +else |
| 61 | + echo "Unknown command '${1}'" |
| 62 | + exit 1 |
| 63 | +fi |
| 64 | +``` |
| 65 | + |
| 66 | +#### Gopass |
| 67 | + |
| 68 | +The following credential helper can be used to store credentials in [`gopass`](https://www.gopass.pw/): |
| 69 | + |
| 70 | +```sh |
| 71 | +#!/bin/sh |
| 72 | +set -e |
| 73 | +if [ "${1}" = "insert" ]; then |
| 74 | + exec gopass insert -f "misc/enarx/${2}" |
| 75 | +elif [ "${1}" = "show" ]; then |
| 76 | + gopass find misc/enarx 1>/dev/null 2>/dev/null |
| 77 | + exec gopass show -n -o "misc/enarx/${2}" |
| 78 | +else |
| 79 | + echo "Unknown command '${1}'" |
| 80 | + exit 1 |
| 81 | +fi |
| 82 | +``` |
0 commit comments