# Create Admin User Guide

## ✅ Admin User Created Successfully!

An admin user has been created in your MySQL database:

- **Username**: `admin`
- **Password**: `admin123` (or the password you provided)
- **Role**: `ROLE_ADMINISTRATOR`
- **User ID**: 1

## Database Tables Used

### 1. `alf_authority` - Main User/Role Table
- Stores users, roles, and groups
- **Admin user**: `authority = 'admin'`
- **Admin role**: `authority = 'ROLE_ADMINISTRATOR'`

### 2. `alf_authority_alias` - Role Assignments
- Links users to roles
- Connects admin user to ROLE_ADMINISTRATOR

## How to Create More Admin Users

### Option 1: Use the Script
```bash
cd /home/stark/Downloads/PLAGIS_AUMENTUM-main
source venv/bin/activate
export CONTENTSTORE_BASE=~/aumentum_contentstore

# Create admin with password prompt
python3 create_admin_user.py --username myadmin

# Or specify password directly
python3 create_admin_user.py --username myadmin --password mypassword123
```

### Option 2: Manual SQL Insert
```sql
-- 1. Create user in alf_authority
INSERT INTO alf_authority (id, version, authority, crc)
VALUES (2, 1, 'myadmin', CRC32('myadmin'));

-- 2. Link to ROLE_ADMINISTRATOR (if role exists)
INSERT INTO alf_authority_alias (id, version, auth_id, alias_id)
VALUES (1, 1, 2, <ROLE_ADMINISTRATOR_ID>);
```

## Password Storage

**Important**: The current authentication system (`auth_service.py`) checks users in `alf_authority` but may not verify passwords from the database. 

The password you set is for:
- **Application-level authentication** (if implemented)
- **Future password verification** (when password storage is clarified)

## Testing Login

You can test the admin login:

```bash
# Test via API
curl -X POST "http://localhost:8000/auth/login" \
  -H "Content-Type: application/x-www-form-urlencoded" \
  -d "username=admin&password=admin123"
```

## Current Status

✅ Admin user created in `alf_authority`  
✅ ROLE_ADMINISTRATOR role created  
✅ User linked to role via `alf_authority_alias`  
⚠️ Password verification may need additional setup

## Next Steps

1. **Test login** with the created admin credentials
2. **Verify authentication** works in your application
3. **Create additional users** as needed using the script

