Skip to content

Commit

Permalink
Ticket #821 : Login can be an email
Browse files Browse the repository at this point in the history
  • Loading branch information
thabart committed Nov 23, 2024
1 parent a0200c7 commit fe80c84
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/IdServer/SimpleIdServer.IdServer/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -842,7 +842,7 @@ public static class StandardGroups
public static class StandardUsers
{
public static User AdministratorUser = UserBuilder.Create("administrator", "password", "Administrator").SetFirstname("Administrator").SetEmail("[email protected]").SetPicture("https://cdn-icons-png.flaticon.com/512/149/149071.png").AddGroup(StandardGroups.AdministratorGroup).GenerateRandomTOTPKey().Build();
public static User AdministratorReadonlyUser = UserBuilder.Create("administrator-ro", "password", "AdministratorRo").SetFirstname("AdministratorRo").SetEmail("[email protected]").SetPicture("https://cdn-icons-png.flaticon.com/512/149/149071.png").AddGroup(StandardGroups.AdministratorReadonlyGroup).GenerateRandomTOTPKey().Build();
public static User AdministratorReadonlyUser = UserBuilder.Create("administrator-ro", "password", "AdministratorRo").SetFirstname("AdministratorRo").SetEmail("adm-ro@email.com").SetPicture("https://cdn-icons-png.flaticon.com/512/149/149071.png").AddGroup(StandardGroups.AdministratorReadonlyGroup).GenerateRandomTOTPKey().Build();
}

public static class StandardAcrs
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ public static class StringExtensions

public static string Join(this IEnumerable<string> arr, string separator = ",") => string.Join(separator, arr);

public static string SanitizeNameIdentifier(this string nameIdentifier) => nameIdentifier.Replace("\\", string.Empty);
public static string SanitizeNameIdentifier(this string nameIdentifier) => nameIdentifier
.Replace("\\", string.Empty)
.Replace("@", string.Empty);

public static string ExtractAuthorizationValue(this string str, IEnumerable<string> authenticationSchemes)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using SimpleIdServer.IdServer.Helpers;
using SimpleIdServer.IdServer.Middlewares;
using SimpleIdServer.IdServer.SubjectTypeBuilders;
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Text.Json;
Expand Down Expand Up @@ -229,6 +230,7 @@ public class IdServerHostOptions
public string GetSessionCookieName(string userName)
{
var realm = RealmContext.Instance().Realm;
userName = userName.SanitizeNameIdentifier();
if (!string.IsNullOrWhiteSpace(realm))
return $"{SessionCookieName}.{realm}-{userName}";
return $"{SessionCookieName}-{userName}";
Expand Down

0 comments on commit fe80c84

Please sign in to comment.