Introduction
Problem
Terraform Enterprise (TFE) enforces a 40-character limit on usernames. Customers who require users to authenticate with SAML may have users encounter the following error:
An error occurred. Please contact your TFE Administrator for further information.
ERROR: Validation failed: Username cannot have more than 40 characters
Prerequisites
- Ability to SSH to TFE instance with sudo access
Cause
This error is caused because SAML SSO auto-assigns a username based on the user's email which exceeds the 40-character limit.
Overview of possible solution
Solution:
1. SSH to the TFE instance and connect to Rails using this guide.
2. Update <email@email.com> with the user's email, <customusername> with a username, and <Password123> with a password, then run the following command
u = User.create!(email: "email@email.com", username: "customusername", password: "Password123", is_admin: false)
3. Run the following command to confirm the user.
u.confirm
4. Run the following command to save the user
u.save
Outcome:
Once the user has been manually created, the user will be able to successfully login using SAML SSO.