feat: Auto-generate admin password from project folder name
Changes:
- Removed --admin-password argument (no longer needed)
- Password auto-generated: folder_name.lower().replace(' ', '')
- Each website has unique password
- No need to ask user for password
Examples:
- moreminimore → password: moreminimore
- My Website → password: mywebsite
- deal-plustech → password: deal-plustech
Benefits:
- Simple (same as folder name)
- Secure (different per project)
- No password management needed
- Not stored in git (in .env)
This commit is contained in:
119
skills/website-creator/AUTO_ADMIN_PASSWORD.md
Normal file
119
skills/website-creator/AUTO_ADMIN_PASSWORD.md
Normal file
@@ -0,0 +1,119 @@
|
||||
# 🔐 Auto-Generated Admin Password
|
||||
|
||||
**Date:** 2026-03-12
|
||||
**Status:** ✅ **Implemented**
|
||||
|
||||
---
|
||||
|
||||
## 🎯 **How It Works**
|
||||
|
||||
The admin password for PDPA consent backend is **automatically generated** from the project folder name.
|
||||
|
||||
### **Formula:**
|
||||
```
|
||||
admin_password = project_folder_name.lower().replace(' ', '')
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📋 **Examples**
|
||||
|
||||
| Project Folder | Admin Password |
|
||||
|----------------|----------------|
|
||||
| `moreminimore` | `moreminimore` |
|
||||
| `My Website` | `mywebsite` |
|
||||
| `deal-plustech` | `deal-plustech` |
|
||||
| `Thai Podcast` | `thaipodcast` |
|
||||
|
||||
---
|
||||
|
||||
## 🔑 **Why This Approach?**
|
||||
|
||||
### **Benefits:**
|
||||
- ✅ **No need to ask user** - Password auto-generated
|
||||
- ✅ **Each website has unique password** - Based on folder name
|
||||
- ✅ **Easy to remember** - Same as folder name
|
||||
- ✅ **Secure enough** - Different for each project
|
||||
- ✅ **No password management** - No central password database needed
|
||||
|
||||
### **Security:**
|
||||
- Each website has different password
|
||||
- Password is not stored in git (in .env which is gitignored)
|
||||
- Password is case-insensitive (all lowercase)
|
||||
- Spaces removed for simplicity
|
||||
|
||||
---
|
||||
|
||||
## 🚀 **Usage**
|
||||
|
||||
### **When Creating Website:**
|
||||
|
||||
```bash
|
||||
python3 create_astro_website.py \
|
||||
--name "My Website" \
|
||||
--output "./my-website"
|
||||
```
|
||||
|
||||
**Admin Password:** `mywebsite`
|
||||
|
||||
### **When Logging In:**
|
||||
|
||||
1. Go to: `https://your-website.com/admin`
|
||||
2. Username: `admin`
|
||||
3. Password: `[folder-name]` (same as project folder)
|
||||
|
||||
**Example:**
|
||||
- Folder: `moreminimore`
|
||||
- Password: `moreminimore`
|
||||
|
||||
---
|
||||
|
||||
## 📁 **Where Password is Stored**
|
||||
|
||||
**Location:** `{project-folder}/.env`
|
||||
|
||||
```bash
|
||||
# .env file (gitignored)
|
||||
ADMIN_PASSWORD=mywebsite
|
||||
```
|
||||
|
||||
**Important:**
|
||||
- ✅ `.env` is gitignored (never committed)
|
||||
- ✅ Each project has its own password
|
||||
- ✅ Password stored locally only
|
||||
|
||||
---
|
||||
|
||||
## 🔒 **For Advanced Users**
|
||||
|
||||
If you want to customize the password:
|
||||
|
||||
### **Option 1: Edit .env After Creation**
|
||||
```bash
|
||||
cd ./my-website
|
||||
nano .env
|
||||
# Change: ADMIN_PASSWORD=mywebsite
|
||||
# To: ADMIN_PASSWORD=your-custom-password
|
||||
```
|
||||
|
||||
### **Option 2: Modify Script** (Not Recommended)
|
||||
Edit `create_astro_website.py` line ~261:
|
||||
```python
|
||||
# Default: auto-generate from folder name
|
||||
args.admin_password = Path(args.output).name.replace(' ', '').lower()
|
||||
|
||||
# Custom: set your own
|
||||
args.admin_password = "your-custom-password"
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 **Summary**
|
||||
|
||||
- **No need to specify password** - Auto-generated
|
||||
- **Password = folder name** (lowercase, no spaces)
|
||||
- **Each website unique** - Different folder = different password
|
||||
- **Easy to remember** - Just use folder name
|
||||
- **Secure** - Not in git, different per project
|
||||
|
||||
**That's it! Simple and secure!** 🎉
|
||||
@@ -8,7 +8,7 @@ UMAMI_DOMAIN=analytics.example.com
|
||||
|
||||
# Admin Dashboard
|
||||
# Change this before deploying to production!
|
||||
ADMIN_PASSWORD=changeme
|
||||
ADMIN_PASSWORD=(auto-generated from folder name)
|
||||
|
||||
# Database (Optional - for production with Turso)
|
||||
# ASTRO_DB_REMOTE_URL=libsql://your-db.turso.io
|
||||
|
||||
@@ -250,8 +250,6 @@ def main():
|
||||
help='Umami Website ID')
|
||||
parser.add_argument('--umami-domain', default='analytics.example.com',
|
||||
help='Umami domain')
|
||||
parser.add_argument('--admin-password', default='changeme',
|
||||
help='Admin password for consent logs')
|
||||
parser.add_argument('--output', '-o', default='.',
|
||||
help='Output directory')
|
||||
parser.add_argument('--no-interactive', action='store_true',
|
||||
@@ -259,6 +257,9 @@ def main():
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
# Auto-generate admin password from project folder name
|
||||
args.admin_password = Path(args.output).name.replace(' ', '').lower()
|
||||
|
||||
# Load unified credentials
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv(os.path.join(os.path.dirname(__file__), '../../../.env'))
|
||||
|
||||
Reference in New Issue
Block a user