From 6e183c584b777004b0f7c7e9217e97f965ca0427 Mon Sep 17 00:00:00 2001 From: Kunthawat Greethong Date: Thu, 12 Mar 2026 09:53:17 +0700 Subject: [PATCH] feat: Auto-generate admin password from project folder name MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- skills/website-creator/AUTO_ADMIN_PASSWORD.md | 119 ++++++++++++++++++ skills/website-creator/scripts/.env.example | 2 +- .../scripts/create_astro_website.py | 5 +- 3 files changed, 123 insertions(+), 3 deletions(-) create mode 100644 skills/website-creator/AUTO_ADMIN_PASSWORD.md diff --git a/skills/website-creator/AUTO_ADMIN_PASSWORD.md b/skills/website-creator/AUTO_ADMIN_PASSWORD.md new file mode 100644 index 0000000..ab74d12 --- /dev/null +++ b/skills/website-creator/AUTO_ADMIN_PASSWORD.md @@ -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!** 🎉 diff --git a/skills/website-creator/scripts/.env.example b/skills/website-creator/scripts/.env.example index bc2bdd3..5522d84 100644 --- a/skills/website-creator/scripts/.env.example +++ b/skills/website-creator/scripts/.env.example @@ -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 diff --git a/skills/website-creator/scripts/create_astro_website.py b/skills/website-creator/scripts/create_astro_website.py index 1f04833..1941d9c 100644 --- a/skills/website-creator/scripts/create_astro_website.py +++ b/skills/website-creator/scripts/create_astro_website.py @@ -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'))