Encrypt API tokens (#2360)

Store API tokens encrypted in the database.

During the database migration a randomly generated key will be used encrypt the tokens if no ENCRYPTION_KEY environment variable was provided.

If the application is started without the presence of an ENCRYPTION_KEY (or if the key failed to decrypt the existing tokens), the UI will display a warning with further instructions.
This commit is contained in:
Adrian Kumpf
2022-02-18 17:03:13 +01:00
committed by GitHub
parent d461292bc4
commit 0d6e288c70
37 changed files with 2629 additions and 1867 deletions

View File

@@ -26,8 +26,9 @@ This setup is recommended only if you are running TeslaMate **on your home netwo
image: teslamate/teslamate:latest
restart: always
environment:
- ENCRYPTION_KEY= #insert a secure key to encrypt your Tesla API tokens
- DATABASE_USER=teslamate
- DATABASE_PASS= #insert your secure password!
- DATABASE_PASS= #insert your secure database password!
- DATABASE_NAME=teslamate
- DATABASE_HOST=database
- MQTT_HOST=mosquitto
@@ -43,7 +44,7 @@ This setup is recommended only if you are running TeslaMate **on your home netwo
restart: always
environment:
- POSTGRES_USER=teslamate
- POSTGRES_PASSWORD= #insert your secure password!
- POSTGRES_PASSWORD= #insert your secure database password!
- POSTGRES_DB=teslamate
volumes:
- teslamate-db:/var/lib/postgresql/data
@@ -53,7 +54,7 @@ This setup is recommended only if you are running TeslaMate **on your home netwo
restart: always
environment:
- DATABASE_USER=teslamate
- DATABASE_PASS= #insert your secure password!
- DATABASE_PASS= #insert your secure database password!
- DATABASE_NAME=teslamate
- DATABASE_HOST=database
ports:
@@ -78,9 +79,9 @@ This setup is recommended only if you are running TeslaMate **on your home netwo
mosquitto-data:
```
2. Choose your secure database password and insert it at every occurence of `DATABASE_PASS` and `POSTGRES_PASSWORD`
3. Start the docker containers with `docker-compose up`. To run the containers in the background add the `-d` flag:
2. **Choose a secure encryption key** that will be used to encrypt your Tesla API tokens (insert as `ENCRYPTION_KEY`).
3. **Choose your secure database password** and insert it at every occurence of `DATABASE_PASS` and `POSTGRES_PASSWORD`
4. Start the docker containers with `docker-compose up`. To run the containers in the background add the `-d` flag:
```bash
docker-compose up -d