Skip to content

Commit 78078ab

Browse files
docs: enhance README with detailed instructions for generating SECRET_KEY and RSA keys (#267)
1 parent e324864 commit 78078ab

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

README.md

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,38 @@
4242
cp .env.example .env
4343
```
4444
- Edit the `.env` file and update the values according to your setup:
45-
- `SECRET_KEY`: Generate a unique secret key for Django
45+
- `SECRET_KEY`: Generate a unique secret key for Django using one of these methods:
46+
```bash
47+
# Method 1: Using Django's built-in utility (Recommended)
48+
python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
49+
50+
# Method 2: Using Python's secrets module
51+
python -c "import secrets; print(secrets.token_urlsafe(50))"
52+
53+
# Method 3: Using openssl (if available)
54+
openssl rand -base64 50
55+
```
4656
- `MONGODB_URI`: MongoDB connection string (default: `mongodb://localhost:27017`)
4757
- `DB_NAME`: Your database name
4858
- `GOOGLE_OAUTH_CLIENT_ID` and `GOOGLE_OAUTH_CLIENT_SECRET`: OAuth credentials for Google authentication
49-
- `PRIVATE_KEY` and `PUBLIC_KEY`: Generate RSA key pairs for JWT token signing
59+
- `PRIVATE_KEY` and `PUBLIC_KEY`: Generate RSA key pairs for JWT token signing using one of these methods:
60+
```bash
61+
# Method 1: Using openssl (Recommended)
62+
# Generate private key (2048-bit RSA)
63+
openssl genrsa -out private_key.pem 2048
64+
65+
# Generate public key from private key
66+
openssl rsa -in private_key.pem -pubout -out public_key.pem
67+
68+
# View the keys and copy them to your .env file
69+
cat private_key.pem
70+
cat public_key.pem
71+
72+
# Method 2: Using ssh-keygen
73+
ssh-keygen -t rsa -b 2048 -m PEM -f jwt_key -N ''
74+
openssl rsa -in jwt_key -pubout -out jwt_key.pub
75+
```
76+
**Note**: Copy the entire content including `-----BEGIN...-----` and `-----END...-----` headers
5077
- Other settings can be left as default for local development
5178
7. Install [docker](https://docs.docker.com/get-docker/) and [docker compose](https://docs.docker.com/compose/install/)
5279
8. Start MongoDB using docker

0 commit comments

Comments
 (0)