Moved key generate to bash script

This commit is contained in:
Benjamin Sherriff
2024-01-29 22:12:59 -05:00
parent 4609be84a8
commit d74e8e181b
4 changed files with 26 additions and 9 deletions

View File

@@ -73,4 +73,4 @@ docker run --env-file .env -it --rm --name siren siren:latest
### Authentication
The Siren service uses a JWT/session based authentication system, in that JWT tokens are issued and used, but a state is also kept server-side. This is to allow for the ability to revoke and expire tokens, as well as to allow for the ability to have multiple tokens per user.
Public/Private keys can be generated with `make generate`. These keys should be located within a `/keys` directory in the root of the project.
Public/Private keys can be generated with `./generate_keys.sh`. These keys should be located within a `/keys` directory in the root of the project. The service's .env file should be updated to reflect the location of the keys.

23
generate_keys.sh Executable file
View File

@@ -0,0 +1,23 @@
#! /bin/bash
DIR="./keys"
if [ "$#" -eq 1 ]; then
DIR=$1
fi
# Create the keys directory (if it doesn't exist)
echo "Generating keys in: $DIR"
mkdir -p "$DIR"
# Generate Access Keys
openssl genrsa -out $DIR/access_private_key.pem 4096
openssl rsa -in $DIR/access_private_key.pem -pubout -outform PEM -out $DIR/access_public_key.pem
chmod 600 $DIR/access_private_key.pem
chmod 644 $DIR/access_public_key.pem
# Generate Refresh Keys
openssl genrsa -out $DIR/refresh_private_key.pem 4096
openssl rsa -in $DIR/refresh_private_key.pem -pubout -outform PEM -out $DIR/refresh_public_key.pem
chmod 600 $DIR/refresh_private_key.pem
chmod 644 $DIR/refresh_public_key.pem

View File

@@ -25,3 +25,4 @@ DATA_DIR_PATH=
DISCORD_TOKEN=
OPENAI_API_KEY=
OPENAI_API_MODEL=gpt-3.5-turbo

View File

@@ -29,10 +29,3 @@ clean:
docker image rm siren-service || \
docker network rm siren_frontend || \
docker network rm siren-backend
generate: ## Generate RSA keys
mkdir keys
openssl genrsa -out keys/access_private_key.pem 4096
openssl rsa -in keys/access_private_key.pem -pubout -outform PEM -out keys/access_public_key.pem
openssl genrsa -out keys/refresh_private_key.pem 4096
openssl rsa -in keys/refresh_private_key.pem -pubout -outform PEM -out keys/refresh_public_key.pem