Temporary User Access
Overview
At checkout, the broker creates a temporary MySQL user with ALL privileges on the target database. At checkin, the user is dropped. This pattern grants full database-level access for admin or DBA sessions — use it only when scoped role access is insufficient.
Before You Begin
- The broker is running and connected (see Getting Started)
mysqlclient,awsCLI, andjqare installed on the broker host- The broker service account has
CREATE USER,GRANT ALL, andDROP USERprivileges
Checkout Routine
Full script: Aurora MySQL/permissions/temp-user/
Environment variables:
| Variable | Notes |
|---|---|
user | Injected — requesting user’s email |
host | Aurora cluster endpoint |
dburl | Same as host |
secret | AWS Secrets Manager secret name or ARN |
Create temp user with ALL privileges:
DB_USER=$(echo "$user" | cut -d'@' -f1 | tr -cd '[:alnum:]')
DB_PASSWORD=$(openssl rand -base64 16 | tr -d '=/+')
SECRET_JSON=$(aws secretsmanager get-secret-value --secret-id "$secret" --query SecretString --output text)
ADMIN_USER=$(echo "$SECRET_JSON" | jq -r '.username')
ADMIN_PASS=$(echo "$SECRET_JSON" | jq -r '.password')
mysql -h "$dburl" -u "$ADMIN_USER" -p"$ADMIN_PASS" <<EOF
CREATE USER IF NOT EXISTS '${DB_USER}'@'%' IDENTIFIED BY '${DB_PASSWORD}';
GRANT ALL PRIVILEGES ON systemdb.* TO '${DB_USER}'@'%';
FLUSH PRIVILEGES;
EOF
echo "username=${DB_USER}"
echo "password=${DB_PASSWORD}"
echo "host=${host}"Checkin Routine
Full script: Aurora MySQL/permissions/temp-user/
DB_USER=$(echo "$user" | cut -d'@' -f1 | tr -cd '[:alnum:]')
SECRET_JSON=$(aws secretsmanager get-secret-value --secret-id "$secret" --query SecretString --output text)
ADMIN_USER=$(echo "$SECRET_JSON" | jq -r '.username')
ADMIN_PASS=$(echo "$SECRET_JSON" | jq -r '.password')
mysql -h "$dburl" -u "$ADMIN_USER" -p"$ADMIN_PASS" <<EOF
DROP USER IF EXISTS '${DB_USER}'@'%';
FLUSH PRIVILEGES;
EOF
echo "User ${DB_USER} dropped."This pattern grants ALL PRIVILEGES on the target database — use for admin sessions only. For day-to-day developer or analyst access, use Role-Based Access to limit the privilege to what the user actually needs.
Configure in Britive
Create a response template
Go to Resource Manager → Response Templates → New Template. Add fields for username, password, and host.
Create a permission
Go to Resource Manager → Resource Type Permissions → New Permission. Set Language to Shell.
Paste the checkout and checkin routines. Declare variables:
| Variable | System defined | Notes |
|---|---|---|
user | Yes | Injected automatically |
host | No | Set per resource |
dburl | No | Set per resource |
secret | No | Set per resource |
Under Response Templates, attach the template you created.
Create a profile
Go to Resource Manager → Profiles → New Profile. Set a short expiration (e.g. 2h). Under Associations, select the resource label(s). Under Permissions, add this permission.
Add a policy with approval
Under Policies, assign members and add an approval condition — this pattern grants full database access and should require manager or DBA team approval.
Verify
Check out the profile
Navigate to My Access → find the profile → Check Out. Credentials appear in the response.
Connect and verify access
mysql -h <host> -u <username> -p<password> systemdbSELECT current_user();
SHOW GRANTS;
-- Expected: GRANT ALL PRIVILEGES ON systemdb.* TO 'username'@'%'Check in
Return to My Access → Check In.
Confirm the user is dropped
mysql -h <host> -u <username> -p<password> systemdb
# Expected: ERROR 1045 (28000): Access deniedTroubleshoot
| Symptom | Cause | Fix |
|---|---|---|
GRANT ALL failed | britive_svc lacks GRANT OPTION | Add WITH GRANT OPTION to the service account’s grants |
| User still exists after checkin | Active connection held the session | Kill the session manually: KILL CONNECTION <id>;, then retry checkin |
Access denied on Secrets Manager | IAM role missing permission | Attach secretsmanager:GetSecretValue to the broker instance profile |