feat: support secret rotation and https redirection #7
@ -9,8 +9,9 @@ ADMIN_FORCE_MFA=true
|
||||
|
||||
LOG_LEVEL=info
|
||||
|
||||
SECRET_ENC_KEYS_VERSION=v1
|
||||
ENC_KEY_ACTIVE=""
|
||||
SECRET_ENC_KEYS_A_VERSION=a1 # generate=false
|
||||
|
cyrnel marked this conversation as resolved
Outdated
|
||||
SECRET_ENC_KEYS_B_VERSION=b1 # generate=false
|
||||
ENC_KEY_ACTIVE="a1"
|
||||
|
||||
SECRET_HQL_RAFT_VERSION=v1
|
||||
SECRET_HQL_API_VERSION=v1
|
||||
|
||||
37
README.md
37
README.md
@ -17,20 +17,16 @@
|
||||
|
||||
## Quick start
|
||||
|
||||
* `abra app new rauthy`
|
||||
1. `abra app new rauthy`
|
||||
2. `abra app cmd --local <app> generate_enc_keys`
|
||||
3. `abra app secret generate <app> --all`
|
||||
4. `abra app deploy <app>`
|
||||
5. `abra app logs <app>`
|
||||
- You'll see the automatically generated admin password in the initial logs.
|
||||
Ensure that you reset this password after you log in. The `ADMIN_EMAIL` env
|
||||
var controls the value of the admin login username.
|
||||
|
||||
### Generate encryption keys
|
||||
|
||||
* `echo "$(openssl rand -hex 4)/$(openssl rand -base64 32)"`
|
||||
* `abra app secret insert <app> enc_keys v1 <enc-key>`
|
||||
* `abra app config <app>`
|
||||
* **N.B** you need to match the `ENC_KEY_ACTIVE` env var with the start of
|
||||
the generated `enc_keys` value (everything before the `/`. See [the
|
||||
docs](https://sebadob.github.io/rauthy/config/encryption.html) for more)
|
||||
|
||||
### Generate secrets
|
||||
|
||||
* `abra app secret generate <app> -a`
|
||||
For more, see [`docs.coopcloud.tech`](https://docs.coopcloud.tech).
|
||||
|
||||
### Host mode networking
|
||||
|
||||
@ -41,12 +37,13 @@ mistakenly rate limited based on internal ipv4 addresses (e.g. `10.0.0.6`).
|
||||
COMPOSE_FILE="$COMPOSE_FILE:compose.host.yml"
|
||||
```
|
||||
|
||||
### Deploy
|
||||
### Encryption key rotation
|
||||
|
||||
* `abra app deploy <app>`
|
||||
* `abra app logs <app>`
|
||||
* You'll see the automatically generated admin password in the initial logs.
|
||||
Ensure that you reset this password after you log in. The `ADMIN_EMAIL` env
|
||||
var controls the value of the admin login username.
|
||||
This recipe supports encryption key rotation as described in [the docs](https://sebadob.github.io/rauthy/config/encryption.html). To rotate keys the first time:
|
||||
|
||||
For more, see [`docs.coopcloud.tech`](https://docs.coopcloud.tech).
|
||||
1. Increment the version of `SECRET_ENC_KEYS_B_VERSION=b1` to `b2`
|
||||
2. `abra app secret insert <app> enc_keys_b b2 "$(openssl rand -base64 32)"`
|
||||
2. Change `ENC_KEY_ACTIVE="a1"` to `b2` (this tells rauthy to encrypt new secrets with the new key while still having access to `a1`)
|
||||
3. `abra app deploy <app>`
|
||||
|
||||
To rotate keys any future time, follow the same pattern of incrementing the non-active secret version and changing the active secret to that newly generated secret.
|
||||
|
||||
12
abra.sh
12
abra.sh
@ -1 +1,13 @@
|
||||
set -e
|
||||
|
||||
export CONFIG_TOML_VERSION=v2
|
||||
|
||||
generate_enc_keys() {
|
||||
KEY_A="$(openssl rand -base64 32)"
|
||||
KEY_B="$(openssl rand -base64 32)"
|
||||
abra app secret insert "$APP_NAME" enc_keys_a a1 "$KEY_A" --chaos
|
||||
|
cyrnel marked this conversation as resolved
decentral1se
commented
Reminds me of toolshed/abra#571 btw Reminds me of https://git.coopcloud.tech/toolshed/abra/issues/571 btw
|
||||
abra app secret insert "$APP_NAME" enc_keys_b b1 "$KEY_B" --chaos
|
||||
echo "WARNING: secrets are NOT shown again, please save them NOW"
|
||||
echo " enc_keys_a $KEY_A"
|
||||
echo " enc_keys_b $KEY_B"
|
||||
}
|
||||
|
||||
@ -1,6 +1,3 @@
|
||||
---
|
||||
version: "3.13"
|
||||
|
||||
services:
|
||||
app:
|
||||
environment:
|
||||
|
||||
16
compose.yml
16
compose.yml
@ -1,6 +1,3 @@
|
||||
---
|
||||
version: "3.13"
|
||||
|
||||
services:
|
||||
app:
|
||||
image: ghcr.io/sebadob/rauthy:0.32.2
|
||||
@ -14,7 +11,8 @@ services:
|
||||
- source: config_toml
|
||||
target: /app/config.toml
|
||||
secrets:
|
||||
- enc_keys
|
||||
- enc_keys_a
|
||||
- enc_keys_b
|
||||
- hql_api
|
||||
- hql_raft
|
||||
volumes:
|
||||
@ -30,6 +28,9 @@ services:
|
||||
- "traefik.http.routers.${STACK_NAME}.rule=Host(`${DOMAIN}`)"
|
||||
- "traefik.http.routers.${STACK_NAME}.entrypoints=web-secure"
|
||||
- "traefik.http.routers.${STACK_NAME}.tls.certresolver=${LETS_ENCRYPT_ENV}"
|
||||
- "traefik.http.routers.${STACK_NAME}.middlewares=${STACK_NAME}-redirect"
|
||||
- "traefik.http.middlewares.${STACK_NAME}-redirect.redirectscheme.scheme=https"
|
||||
- "traefik.http.middlewares.${STACK_NAME}-redirect.redirectscheme.permanent=true"
|
||||
- "coop-cloud.${STACK_NAME}.version=0.4.0+0.32.2"
|
||||
|
||||
networks:
|
||||
@ -43,8 +44,11 @@ configs:
|
||||
template_driver: golang
|
||||
|
||||
secrets:
|
||||
enc_keys:
|
||||
name: ${STACK_NAME}_enc_keys_${SECRET_ENC_KEYS_VERSION}
|
||||
enc_keys_a:
|
||||
name: ${STACK_NAME}_enc_keys_a_${SECRET_ENC_KEYS_A_VERSION}
|
||||
external: true
|
||||
enc_keys_b:
|
||||
name: ${STACK_NAME}_enc_keys_b_${SECRET_ENC_KEYS_B_VERSION}
|
||||
external: true
|
||||
hql_raft:
|
||||
name: ${STACK_NAME}_hql_raft_${SECRET_HQL_RAFT_VERSION}
|
||||
|
||||
@ -24,7 +24,8 @@ level = '{{ env "LOG_LEVEL" }}'
|
||||
|
||||
[encryption]
|
||||
keys = [
|
||||
'{{ secret "enc_keys" }}'
|
||||
'{{ env "SECRET_ENC_KEYS_A_VERSION" }}/{{ secret "enc_keys_a" }}',
|
||||
'{{ env "SECRET_ENC_KEYS_B_VERSION" }}/{{ secret "enc_keys_b" }}'
|
||||
]
|
||||
key_active = '{{ env "ENC_KEY_ACTIVE" }}'
|
||||
|
||||
|
||||
22
release/next
Normal file
22
release/next
Normal file
@ -0,0 +1,22 @@
|
||||
WARNING! ⚠️
|
||||
This release supports encryption key rotation, which unfortunately requires some migration steps:
|
||||
|
||||
1. Obtain your old encryption key (enc_keys) if you backed it up. If not, you can extract your current encryption key from the config file. This is pretty advanced and can only be done from the server itself:
|
||||
|
||||
docker secret list # to obtain the secret's full name
|
||||
docker service create --name temp-reader --secret <secret-name> --mode replicated-job alpine:latest sh -c "cat /run/secrets/<secret-name>" && docker service logs --raw temp-reader && echo && docker service rm temp-reader
|
||||
|
||||
NOTE: the encryption key is only the characters AFTER the "/"
|
||||
|
||||
2. Add these lines to your config, overwriting the existing SECRET_ENC_KEYS_VERSION and ENC_KEY_ACTIVE values:
|
||||
|
||||
SECRET_ENC_KEYS_A_VERSION=a1 # generated=false
|
||||
SECRET_ENC_KEYS_B_VERSION=b1 # generated=false
|
||||
ENC_KEY_ACTIVE="a1"
|
||||
|
||||
3. Set key_a and generate key_b:
|
||||
|
||||
abra app secret insert $STACK_NAME enc_keys_a a1 "<your-existing-secret>" -C
|
||||
abra app secret insert $STACK_NAME enc_keys_b b1 "$(openssl rand -base64 32)" -C
|
||||
|
||||
Then you can deploy :)
|
||||
Reference in New Issue
Block a user
❓ toolshed/abra#665 (comment) ❓