|
1 | | -# secrethub-proxy |
| 1 | +<p align="center"> |
| 2 | + <img src="https://secrethub.io/img/secrethub-logo.svg" alt="SecretHub" width="380px"/> |
| 3 | +</p> |
| 4 | +<h1 align="center"> |
| 5 | + <i>HTTP Proxy<sup><a href="#beta">BETA</a></sup></i> |
| 6 | +</h1> |
| 7 | + |
| 8 | +The SecretHub HTTP Proxy adds a RESTful interface to the [SecretHub Client](https://github.com/secrethub/secrethub-go). |
| 9 | +Apps can this way still use SecretHub, without having to directly include the client as a binary dependency. |
| 10 | + |
| 11 | +You can configure it with a SecretHub credential at start, thereby removing the need of passing it in on every request. |
| 12 | + |
| 13 | +> [SecretHub](https://secrethub.io) is a developer tool to help you keep database passwords, API tokens, and other secrets out of IT automation scripts. |
| 14 | +
|
| 15 | +### A note on security |
| 16 | + |
| 17 | +The SecretHub HTTP Proxy opens up the configured SecretHub account over HTTP. |
| 18 | +This moves the responsibility of securing your secrets to the domain of network security, which comes with its own risks. |
| 19 | +So use this with caution and make sure the credential you pass in only has access to only those secrets it needs. |
| 20 | + |
| 21 | +It is recommended to [create a service account](https://secrethub.io/docs/reference/service-command/), tightly control it with [access rules](https://secrethub.io/docs/reference/acl-command/), and use the service credential instead of your own SecretHub account. |
| 22 | + |
| 23 | +``` |
| 24 | +secrethub service init my-org/my-repo --permission read --desc my-app |
| 25 | +``` |
| 26 | + |
| 27 | +## Installation |
| 28 | + |
| 29 | +### Binary |
| 30 | + |
| 31 | +Download and extract the [latest release](https://github.com/keylockerbv/secrethub-http-proxy/releases/latest) of the SecretHub HTTP Proxy. Start it with your SecretHub credential: |
| 32 | + |
| 33 | +``` |
| 34 | +./secrethub-http-proxy -C $(cat ~/.secrethub/credential) -p 8080 |
| 35 | +``` |
| 36 | + |
| 37 | +If upon signup you've chosen to lock your credential with a passphrase, you will get prompted for your passphrase. |
| 38 | + |
| 39 | +### Docker |
| 40 | + |
| 41 | +You can also run the proxy as a [Docker container](https://hub.docker.com/r/secrethub/http-proxy). |
| 42 | +Assuming you have a SecretHub credential stored in the default `$HOME/.secrethub` location, you can run it with the credential mounted as a volume: |
| 43 | + |
| 44 | +``` |
| 45 | +docker run -p 8080:8080 --name secrethub -v $HOME/.secrethub:/secrethub secrethub/http-proxy |
| 46 | +``` |
| 47 | + |
| 48 | +You can also pass in the credential as an environment variable: |
| 49 | + |
| 50 | +``` |
| 51 | +docker run -p 8080:8080 --name secrethub -e SECRETHUB_CREDENTIAL=$(cat $HOME/.secrethub/credential) secrethub/http-proxy |
| 52 | +``` |
| 53 | + |
| 54 | +If upon signup you've chosen to lock your credential with a passphrase, run the container with `-it` to get prompted for your passphrase. |
| 55 | + |
| 56 | +``` |
| 57 | +docker run -it -p 8080:8080 --name secrethub -e SECRETHUB_CREDENTIAL=$(cat $HOME/.secrethub/credential) secrethub/http-proxy |
| 58 | +``` |
| 59 | + |
| 60 | +Alternatively, the passphrase can be sourced from the `SECRETHUB_CREDENTIAL_PASSPHRASE` environment variable. |
| 61 | + |
| 62 | +## Usage |
| 63 | + |
| 64 | +With the proxy up and running, you can perform the following HTTP requests: |
| 65 | + |
| 66 | +### `/v1beta/secrets/raw/:path` |
| 67 | + |
| 68 | +Example: |
| 69 | + |
| 70 | +``` |
| 71 | +/v1beta/secrets/raw/my-org/my-repo/my-secret |
| 72 | +``` |
| 73 | + |
| 74 | +#### `GET` |
| 75 | + |
| 76 | +Returns the secret contents as bytes. |
| 77 | + |
| 78 | +#### `POST` |
| 79 | + |
| 80 | +Creates or updates a secret. Expects the secret contents as bytes. |
| 81 | + |
| 82 | +#### `DELETE` |
| 83 | + |
| 84 | +Deletes the entire secret and its history. |
| 85 | + |
| 86 | +## BETA |
| 87 | + |
| 88 | +This project is currently in beta and we'd love your feedback! Check out the [issues](https://github.com/keylockerbv/secrethub-http-proxy/issues) and feel free to suggest cool ideas, use cases, or improvements. |
| 89 | + |
| 90 | +Because it's still in beta, you can expect to see some changes introduced. Pull requests are very welcome. |
| 91 | + |
| 92 | +## Terraform State Backend |
| 93 | + |
| 94 | +For those of you using [Terraform](https://www.terraform.io), the SecretHub HTTP Proxy can function as a [Terraform Backend](https://www.terraform.io/docs/backends/index.html) for your `.tfstate`. |
| 95 | +Read more about this on our [blog post](). |
| 96 | + |
| 97 | +## Development |
| 98 | + |
| 99 | +Get the source code: |
| 100 | + |
| 101 | +``` |
| 102 | +git clone https://github.com/keylockerbv/secrethub-http-proxy |
| 103 | +``` |
| 104 | + |
| 105 | +Build it using: |
| 106 | + |
| 107 | +``` |
| 108 | +make build |
| 109 | +``` |
0 commit comments