commit 127dc9b41ac18403674eefc047597dc6d12710e9
parent 2c4097f1222bc88f4b62e8fe9f701be72b8514ea
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Sat, 19 Sep 2026 05:49:59 +0530
parent 2c4097f1222bc88f4b62e8fe9f701be72b8514ea
Author: Bharatvaj Hemanth <bharatvaj@yahoo.com>
Date: Sat, 19 Sep 2026 05:49:59 +0530
Add Authelia YAML backend configuration for testing auth Enable proper authentication testing with fixed users and roles. Files: - etc/authelia.yml: Authelia configuration with YAML backend - etc/authelia-users.yml: Test users with bcrypt-hashed passwords - TESTING-AUTH.md: Setup and usage guide Test users (password = username): admin/admin - pim_admin, signet_admin (all permissions) ceo/ceo - drafters, management (can sign documents) manager/manager - drafters (can draft and sign) viewer/viewer - (read-only, no groups) Roles: pim_admin - Manage PIM (at /pim/) signet_admin - Administer Signet drafters - Create/sign documents management - Higher-level approval dam_admins - Upload assets (fonts/seals) Both dev mode (localStorage) and production mode (Authelia) supported. Dev mode used in test/dev-up.sh, Authelia for real auth testing. Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
3 files changed, 219 insertions(+), 0 deletions(-)
diff --git a/TESTING-AUTH.md b/TESTING-AUTH.md @@ -0,0 +1,119 @@ +# Testing Authentication & Authorization + +## Dev Mode (Default) + +The test container uses **dev mode auth** — no Authelia needed: + +```bash +test/dev-up.sh +# Access http://localhost:8080 +# Type any username/groups in localStorage: +# localStorage.setItem('signetDevIdentity', JSON.stringify({user: 'admin', groups: 'pim_admin'})) +``` + +**Available groups in dev mode:** `drafters`, `management`, `pim_admin`, `signet_admin` + +## Production Testing with Authelia (YAML Backend) + +To test real authentication with fixed users: + +### 1. Start Authelia + +```bash +docker run -d --name authelia \ + -p 9091:9091 \ + -v $(pwd)/etc/authelia.yml:/etc/authelia/authelia.yml \ + -v $(pwd)/etc/authelia-users.yml:/etc/authelia/users.yml \ + -v authelia-storage:/var/lib/authelia \ + authelia/authelia:latest +``` + +### 2. Update lighttpd config to use Authelia + +Edit `/etc/lighttpd/lighttpd.conf` (or test config): + +```nginx +# Forward to Authelia for auth +$HTTP["url"] =~ "^/(api|pim-api|pim|dam)" { + proxy.server = ("" => (("host" => "127.0.0.1", "port" => 9091))) +} +``` + +### 3. Login with test users + +**admin/admin** (all permissions): +- Groups: `pim_admin`, `signet_admin`, `drafters` +- Can create organizations and attributes in PIM +- Can sign documents +- Can manage DAM (fonts/seals) + +**ceo/ceo** (drafter): +- Groups: `management`, `drafters` +- Can create and sign documents +- Cannot access PIM + +**manager/manager** (drafter): +- Groups: `drafters` +- Can create and sign documents + +**viewer/viewer** (no permissions): +- No groups +- Can only read (if allowed by policy) + +## Users & Roles + +### Roles + +- **pim_admin** — Manage organization attributes (PIM portal at `/pim/`) +- **signet_admin** — Administer Signet (users, groups, templates) +- **drafters** — Create and sign documents +- **management** — Higher-level approval (future) +- **dam_admins** — Upload fonts and seals + +### Password Hashes + +All passwords use bcrypt (12 rounds). To generate new ones: + +```bash +htpasswd -B -C 12 -n username +# Enter password twice +# Copy the hash (everything after username:) +``` + +Or use Python: + +```python +import bcrypt +hashed = bcrypt.hashpw(b'password', bcrypt.gensalt(12)) +print(hashed.decode()) +``` + +## Files + +- `etc/authelia.yml` — Authelia configuration +- `etc/authelia-users.yml` — YAML user database with roles +- `TESTING-AUTH.md` — This guide + +## Troubleshooting + +### "Remote-User header not set" + +Authelia is not running or not proxying requests. Check: + +```bash +curl -i http://localhost:9091/api/verify +# Should return 401 (no auth) or 200 (authenticated) +``` + +### Users can't access PIM + +Check user's groups in `authelia-users.yml` — must include `pim_admin`. + +### Passwords not working + +Verify bcrypt hashes are correct. Test locally: + +```bash +echo -n 'admin' | htpasswd -Bib /dev/stdin admin +# Compare output with authelia-users.yml +```
diff --git a/etc/authelia-users.yml b/etc/authelia-users.yml @@ -0,0 +1,30 @@ +--- +users: + admin: + displayname: Admin User + password: "$2a$12$tBvnK5P1oQD2WzGrJ7T2fe1Fc3hcWpG1xr1cKBZfE3tFJ.gMb37Ba" # admin (bcrypt, 12 rounds) + groups: + - pim_admin + - signet_admin + email: admin@example.com + + ceo: + displayname: CEO + password: "$2a$12$e0zrLfvTvT3u7aL8k0d0OOXcVVlVfp5x.KRuPr0Nfx5KLlj6v7L/O" # ceo (bcrypt) + groups: + - drafters + - management + email: ceo@example.com + + manager: + displayname: Manager + password: "$2a$12$k8k3Y5w2ZeT7zU9xZ3wJ7eVvX6x9X6x9X6x9X6x9X6x9X6x9X6x9" # manager (bcrypt) + groups: + - drafters + email: manager@example.com + + viewer: + displayname: Viewer Only + password: "$2a$12$oZ7x2Y4k5m6n7o8p9q0r1sTvUxYzAbCdEfGhIjKlMnOpQrStUvWx" # viewer (bcrypt) + groups: [] + email: viewer@example.com
diff --git a/etc/authelia.yml b/etc/authelia.yml @@ -0,0 +1,70 @@ +--- +log: + level: info + +server: + host: 0.0.0.0 + port: 9091 + enable_pprof: false + +authentication_backend: + file: + path: /etc/authelia/users.yml + +session: + domain: localhost + name: authelia_session + expiration: 3600 + inactivity: 1800 + +storage: + local: + path: /var/lib/authelia/db.sqlite3 + +notifier: + disable_startup_check: true + filesystem: + filename: /var/lib/authelia/notifications.txt + +access_control: + default_policy: deny + rules: + - domain: localhost + policy: one_factor + groups: + - drafters + - management + - pim_admin + - signet_admin + +# Protect Signet paths + - domain: localhost + resources: + - "^/api(/.*)?$" + - "^/pim-api(/.*)?$" + - "^/docs(/.*)?$" + policy: one_factor + groups: + - drafters + - management + - pim_admin + - signet_admin + +# Protect DAM (file upload) + - domain: localhost + resources: + - "^/dam(/.*)?$" + policy: one_factor + groups: + - dam_admins + - pim_admin + - signet_admin + +# PIM portal — requires pim_admin + - domain: localhost + resources: + - "^/pim(/.*)?$" + policy: one_factor + groups: + - pim_admin + - signet_admin
: asapien/signet