LDAP User Seeding
Overview
This document describes the database migration used to seed users from the LDAP configuration into the users table for development and testing scenarios.
Migration Files Created
1. backend/migrations/013_seed_ldap_users.up.sql
- Purpose: Populate users table with LDAP users from ldap-config.cfg
- Method: INSERT with ON CONFLICT DO NOTHING to prevent duplicates
- Scope: 14 LDAP users + 1 system user = 15 total users
- User Fields Populated:
email- Primary identifierfirst_name- From LDAP givenNamelast_name- From LDAP snis_ldap_user- Set totruefor all LDAP usersstatus- Set toactiveemail_verified- Set totrue(LDAP users are trusted)
2. backend/migrations/013_seed_ldap_users.down.sql
- Purpose: Rollback migration to remove seeded LDAP users
- Method: Delete only LDAP users marked with
is_ldap_user = true - Safety: Preserves system users and any manually created users
Seeded Users (14 LDAP Users)
Admin & Leadership
- admin@imagefactory.local - Michael Rodriguez (Central Governance Administrator)
- michael.richardson@imagefactory.local - Michael Richardson (Practice Owner - Compliance)
- bob.smith@imagefactory.local - Bob Smith (Operations Lead)
Security Department
- alice.johnson@imagefactory.local - Alice Johnson (Security Practice Author)
- david.wilson@imagefactory.local - David Wilson (Security Practice Reviewer)
- eve.martinez@imagefactory.local - Eve Martinez (Security Practice Approver)
Compliance Department
- frank.thompson@imagefactory.local - Frank Thompson (CGA Control Reviewer)
- grace.lee@imagefactory.local - Grace Lee (CGA Control Approver)
- carol.davis@imagefactory.local - Carol Davis (Control Governance Manager)
Cloud Infrastructure Department
- sarah.mitchell@imagefactory.local - Sarah Mitchell (Cloud Practice Author)
- mark.anderson@imagefactory.local - Mark Anderson (Cloud Practice Reviewer)
- jennifer.chang@imagefactory.local - Jennifer Chang (Cloud Practice Owner)
Data Privacy Department
- lisa.taylor@imagefactory.local - Lisa Taylor (Data Privacy Practice Author)
- thomas.brown@imagefactory.local - Thomas Brown (Data Privacy Practice Reviewer)
Execution Steps
-
Created Migration Files
013_seed_ldap_users.up.sql- Inserts LDAP users013_seed_ldap_users.down.sql- Rollback script
-
Ran Migration
cd backend && \ IF_AUTH_JWT_SECRET="__SET_BEFORE_DEPLOYMENT__" \ IF_DATABASE_HOST=localhost \ IF_DATABASE_PORT=5432 \ IF_DATABASE_NAME=image_factory_dev \ IF_DATABASE_USER=postgres \ IF_DATABASE_PASSWORD=__SET_BEFORE_DEPLOYMENT__ \ IF_DATABASE_SSL_MODE=disable \ go run cmd/migrate/main.go up --env ../.env.development -
Verified Seeding
SELECT COUNT(*) as total_users, SUM(CASE WHEN is_ldap_user = true THEN 1 ELSE 0 END) as ldap_users FROM users; -- Result: 15 total users, 14 LDAP users
Testing UserManagementPage
With the LDAP users seeded, you can now:
-
Test User Listing
- Navigate to
/admin/users - All 14 LDAP users should be visible in the paginated table
- Test filtering, sorting, and pagination
- Navigate to
-
Test User Operations
- Search: Type names to filter users (e.g., "Alice", "Cloud")
- Filter by Status: All users are "active"
- Edit User: Click "Edit" to modify user details
- Suspend/Activate: Test user status transitions
- Delete: Test user removal (with confirmation)
- View Details: Each row is clickable to view full user info
-
Test Pagination
- Set items per page to 5 and navigate through pages
- Verify prev/next buttons work correctly
-
Test Dark Mode
- Toggle dark mode to verify styling
- Check all user details render correctly
Database Verification
Current user table status:
- Total Users: 15
- LDAP Users: 14 (is_ldap_user = true)
- System Users: 1 (system@imagefactory.local)
All LDAP users have:
- ✅ Active status
- ✅ Email verified
- ✅ First and last names populated
- ✅ LDAP flag set to true
Integration with LDAP Authentication
These seeded users match the GLAuth LDAP configuration, so users can:
- Log in via LDAP with their ldap-config credentials
- Have pre-populated user records in the database
- Be managed through the UserManagementPage admin interface
Rollback Instructions
If needed to rollback the migration:
cd backend && \
IF_AUTH_JWT_SECRET="__SET_BEFORE_DEPLOYMENT__" \
IF_DATABASE_HOST=localhost \
IF_DATABASE_PORT=5432 \
IF_DATABASE_NAME=image_factory_dev \
IF_DATABASE_USER=postgres \
IF_DATABASE_PASSWORD=__SET_BEFORE_DEPLOYMENT__ \
IF_DATABASE_SSL_MODE=disable \
go run cmd/migrate/main.go down
This will:
- Remove all 14 LDAP users
- Preserve system users (system@imagefactory.local)
- Leave database schema intact
Status: ✅ Migration Complete - 14 LDAP Users Seeded Successfully