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
- Ability to SSH to TFE instance with sudo access
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
1. SSH to the TFE instance and connect to Rails using this guide.
2. Update <email@example.com> with the user's email, <customusername> with a username, and <Password123> with a password, then run the following command
u = User.create!(email: "firstname.lastname@example.org", username: "customusername", password: "Password123", is_admin: false)
3. Run the following command to confirm the user.
4. Run the following command to save the user
Once the user has been manually created, the user will be able to successfully login using SAML SSO.