- Newest
- Most votes
- Most comments
the AWS Cognito hosted UI does not seem to offer built-in support for usernames with whitespace characters. The hosted UI has limited customization options, and it doesn't seem to provide a way to alter the validation rules for usernames https://cloudcompiled.com/tutorials/aws-cognito-hosted-ui/ In Cognito, the username value is a separate attribute that users can't change, but developers can use the preferred_username attribute to give users usernames that they can change. If you mark an attribute as an alias, users can sign in with that attribute in place of the username https://docs.aws.amazon.com/cognito/latest/developerguide/user-pool-settings-attributes.html
One possible workaround to your problem might be to use AWS Lambda triggers to perform custom validation of usernames. AWS Cognito lets you customize much of your authentication workflow with AWS Lambda triggers. To add username validation, you can implement a pre-sign-up Lambda trigger, which lets you perform custom validation and accept or deny the registration request. If you want to declare a sign-up as invalid, all you have to do is return an error from the Lambda function. You can also validate other attributes in the same way or add other custom validation by adding additional checks and raising an exception, with a custom message if it fails. https://aws.amazon.com/blogs/aws/safely-validating-usernames-with-amazon-cognito/ In your case, you could potentially create a Lambda function that replaces whitespace characters with another acceptable character (like an underscore) before the username is stored in Cognito. You would need to implement similar logic on the client side to ensure that when users enter their username to log in, any whitespace characters are also replaced with the same character.
Relevant content
- asked 5 months ago
- asked 2 years ago
- AWS OFFICIALUpdated 6 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 8 months ago