-
Notifications
You must be signed in to change notification settings - Fork 862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
InvalidParameterEception even if value is ok. Email to long exception #3565
Comments
It even happens if the email is way shorter than 256 for example 250 characters only |
@joshua-classen Good afternoon. The issue is not reproducible using the code below (used using Amazon.CognitoIdentityProvider;
using Amazon.CognitoIdentityProvider.Model;
using System.Security.Cryptography;
using System.Text;
namespace CognitoIDPTest
{
internal class Program
{
static void Main(string[] args)
{
Amazon.AWSConfigs.LoggingConfig.LogResponses = Amazon.ResponseLoggingOption.Always;
Amazon.AWSConfigs.LoggingConfig.LogTo = Amazon.LoggingOptions.Console;
Amazon.AWSConfigs.AddTraceListener("Amazon", new System.Diagnostics.ConsoleTraceListener());
IAmazonCognitoIdentityProvider _cognitoService = new AmazonCognitoIdentityProviderClient();
string email256Chars = "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijkl@gmail.com";
string userName = "<<username>>";
string password = "<<password>>";
string clientId = "<<appclientid>>";
string clientSecret = "<<appclientsecret>>";
var userAttributes = new List<AttributeType>
{ new() { Name="email", Value = email256Chars } };
var signUpRequest = new SignUpRequest
{
Username = userName,
Password = password,
ClientId = clientId,
UserAttributes = userAttributes,
SecretHash = GetUserPoolSecretHash(userName, clientId, clientSecret)
};
var response = _cognitoService.SignUpAsync(signUpRequest).Result;
}
public static string GetUserPoolSecretHash(string userID, string clientID, string clientSecret)
{
string s = userID + clientID;
byte[] bytes = Encoding.UTF8.GetBytes(clientSecret);
byte[] bytes2 = Encoding.UTF8.GetBytes(s);
return Convert.ToBase64String(new HMACSHA256(bytes).ComputeHash(bytes2));
}
}
} However, while using an email Kindly note that the Do you get this error other than the one you originally reported initially? Could you try using short domain name? Also, in my case, in User pool's Sign Up setting page:
May be Cognito validation is being done in my setup. What are these settings for your user pool. Could you please share non-default User pool and app client settings for your setup? If required, I could open an internal ticket to Cognito team to get their inputs. Thanks, |
I found my error on a different location. Before I signup a user I want to check if the user with this mail already exists and I call this function before.
The Email can be of a valid format for example asdasdfasdfjkhajkshdfjkhajksdhfjkhkajsdhfjkhajksdhfjkhaksjdhfjkhasjkdhfkjhasjkdfhkjashdfjkhajksdhfjkhasdjkfhjkasdfkhasjkdfhjkahsdjkfhjkasdhfjkhasjkdfhjkashdjkfhjkasdhfkjhasdkjfhkjashdfjkhasjkdfhkjashdfkhasjkdfhkjhkdashfkhhhhf@fasdgasgasdgasdkkkkgj.de but then the Filter string is to long and it will throw an exception. Basically you can not filter for correct emails. |
This is really a bug in the filtering technology. It says that the Filter String can only be of max 256 characters lenght. Length Constraints: Maximum length of 256. Required: No Source: https://docs.aws.amazon.com/cognito-user-identity-pools/latest/APIReference/API_ListUsers.html This is a problem because the user is allowed to save an email that has 256 characters. But you can not filter these email because the Filter attribute gets longer because "email = " gets attached. |
Issue is reproducible using code below when using email with 256 characters in public static async Task<UserType?> FindUserByEmailAsync(IAmazonCognitoIdentityProvider cognitoService, string userPoolId, string email)
{
var request = new ListUsersRequest
{
UserPoolId = userPoolId,
Filter = $"email = \"{email}\""
};
try
{
var response = await cognitoService.ListUsersAsync(request);
// because this is then longer than 256 characters
if (response.Users.Any())
{
return response.Users.First();
}
return null;
}
catch (Exception)
{
throw;
}
} @joshua-classen As you rightly pointed out, per AWS Cognito > ListUsers service API reference, Thanks, |
This issue has not received a response in 5 days. If you want to keep this issue open, please just leave a comment below and auto-close will be canceled. |
Describe the bug
Hi, i get an Email should not be longer than 256 characters on a 256 character long email. This is a bug.
Please fix that.
Regression Issue
Expected Behavior
I expect that the Error Message will be correct. The error message says that it would not fail if the email is 256 characters long, but it failed.
Current Behavior
email to long exception for a not to long email
Reproduction Steps
call the SignUpAsync method from IAmazonCognitoIdentityProvider
Possible Solution
Allow or dissallow emails with that length.
Additional Information/Context
No response
AWS .NET SDK and/or Package version used
AWSSDK.CognitoIdentityProvider version 3.7.404.1
Targeted .NET Platform
.NET 8
Operating System and version
Windows 11
The text was updated successfully, but these errors were encountered: