0

We have a .NET Core 3.1 app, usign ASP.NET Core Identity and IdentityServer4. We had a requirement to enable creating new users with special characters in their emails, for instance: sömêthìng@example.com

So, we set this option in Startup.cs (I'm ignoring all other properties for now)

services.Configure<IdentityOptions>(options =>
                                            {
                                                options.User.AllowedUserNameCharacters = null;
                                            });

And it worked, new users could be created.

However, I can not authenticate in the application.

The call to IS4 /connect/userinfo is being successfull, returning the results:

enter image description here

The next call is to the endpoint users/getinfo, but it throws a 502 - Bad Gateway and it only happens when the username/email has special characters (It's worth to mention that the application is not new and the authentication flow has been working fine until now).

The endpoint is not hit by the breakpoint and I could detect any middleware that could be causing this.

However, I noticed in the RequestHeaders > Cookie in Chrome:

enter image description here

The username seems to be encoded, I don't know. And I also don't know if that is the issue for the authentication, but it seems to be.

I also tried to call the endpoint via Postman and the issue is the same. I thought that maybe the token, somehow, could be encoded incorrectly, but it isn't, it's ok. Ah, and we're using Angular 12 as frontend.

Has anyone already faced something like this?

André Miranda
  • 6,420
  • 20
  • 70
  • 94
  • Your question is strange. Generally speaking, you can register successfully, and you can obtain complete information, which should be verifiable. I think it may be that some processing of special characters during login affects a certain part of the IS4 authentication process. Can you add a log to this verification process to record error messages? – Chen Nov 17 '22 at 09:45
  • Could it be that the email is stored as a varchar and not a nvarchar in the database? What does the email look like in the database? is it correct there? – Tore Nestenius Nov 18 '22 at 11:43
  • Does `options.User.AllowedUserNameCharacters = null;` work? I thought you had to do something like [`options.User.AllowedUserNameCharacters =Utilities.GetAllWritableCharacters(encoding: System.Text.Encoding.UTF8);`](https://stackoverflow.com/a/71965457/6717178) – JHBonarius Nov 18 '22 at 15:24

1 Answers1

0

Actually the issue was the email (with the special characters) in bearer token. So, before creating the token, I converted the email to base64 and decoded somewhere. But, the authentication itself worked.

André Miranda
  • 6,420
  • 20
  • 70
  • 94