diff --git a/src/Security/integrations/JSONREPOS/Groups/AdminGroup b/src/Security/integrations/JSONREPOS/Groups/AdminGroup new file mode 100644 index 000000000..d08d72ef2 --- /dev/null +++ b/src/Security/integrations/JSONREPOS/Groups/AdminGroup @@ -0,0 +1,12 @@ +{ + "Changes": [], + "RecordId": null, + "DataEntityId": "AdminGroup", + "Name": "AdminGroup", + "Roles": [ + "Administrator" + ], + "RolesHash": "AQAAAAIAAYagAAAAEKys83RAExNqSZMakYMEvtaLHlF6kI3yWS9gDleKBO6s53gCSfoVkfXD39gPpl4Iiw==", + "Created": "2025-02-11T09:18:36.8940817+01:00", + "Modified": "2025-02-11T09:18:37.1615793+01:00" +} \ No newline at end of file diff --git a/src/Security/integrations/JSONREPOS/Users/ADMIN b/src/Security/integrations/JSONREPOS/Users/ADMIN new file mode 100644 index 000000000..79503f70f --- /dev/null +++ b/src/Security/integrations/JSONREPOS/Users/ADMIN @@ -0,0 +1,26 @@ +{ + "Group": "AdminGroup", + "GroupHash": "AQAAAAIAAYagAAAAEH459fL0GTOvnf5gp7UhOY+JhCPG3eEOZRUUm/6bNmuaIshufALUA26u1tX7DjC/1w==", + "CanUserChangePassword": false, + "RecordId": null, + "DataEntityId": "ADMIN", + "Created": "2025-02-11T09:18:38.5093794+01:00", + "Modified": "2025-02-11T09:18:49.4261626+01:00", + "EnableAutoLogOut": true, + "AutoLogOutTimeOutMinutes": 1, + "Id": "8f025957-3fee-43ab-ba2a-61df8cabe620", + "UserName": "admin", + "NormalizedUserName": "ADMIN", + "Email": null, + "NormalizedEmail": null, + "EmailConfirmed": false, + "PasswordHash": "AQAAAAIAAYagAAAAEEdaOAxx1qP2kSl7IzojBHsGUoK2I7rLguHf7DGXh1S6tuCujkL/NvpcHo7xX9oJvw==", + "SecurityStamp": "0cdd6524-fc36-4f9a-92eb-93c560194e79", + "ConcurrencyStamp": "f32ce433-7d12-4266-9c38-56218e426412", + "PhoneNumber": null, + "PhoneNumberConfirmed": false, + "TwoFactorEnabled": false, + "LockoutEnd": null, + "LockoutEnabled": false, + "AccessFailedCount": 0 +} \ No newline at end of file diff --git a/src/Security/src/AXOpen.Security/Services/IdentityRevalidatingAuthenticationStateProvider.cs b/src/Security/src/AXOpen.Security/Services/IdentityRevalidatingAuthenticationStateProvider.cs index 7c17905cd..a76e7e0cf 100644 --- a/src/Security/src/AXOpen.Security/Services/IdentityRevalidatingAuthenticationStateProvider.cs +++ b/src/Security/src/AXOpen.Security/Services/IdentityRevalidatingAuthenticationStateProvider.cs @@ -34,11 +34,9 @@ IOptions options this.scopeFactory = scopeFactory; this.userStore = userStore; this.options = options; - - Instances++; } - internal static int Instances = 0; + UpperInvariantLookupNormalizer Normalizer = new UpperInvariantLookupNormalizer(); protected override TimeSpan RevalidationInterval => TimeSpan.FromSeconds(30); @@ -62,7 +60,7 @@ protected override async Task ValidateAuthenticationStateAsync( return false; } - var user = await userStore.FindByNameAsync(userPrincipal.Identity.Name, cancellationToken); + var user = await userStore.FindByNameAsync(Normalizer.NormalizeName(userPrincipal.Identity.Name), cancellationToken); if (user == null) { @@ -107,7 +105,7 @@ protected override async Task ValidateAuthenticationStateAsync( } catch (Exception ex) { - throw new Exception("Revalidataion failed", ex); + throw new Exception("Revalidation failed", ex); } } diff --git a/src/security/integrations/axopen_blazor_auth_app/Program.cs b/src/security/integrations/axopen_blazor_auth_app/Program.cs index c0747be8e..41b0c55a4 100644 --- a/src/security/integrations/axopen_blazor_auth_app/Program.cs +++ b/src/security/integrations/axopen_blazor_auth_app/Program.cs @@ -81,11 +81,11 @@ // static (IRepository, IRepository) SetUpMongo(string path = "Blazor") { - var mongoUri = "mongodb://localhost:27017"; - - IRepository userRepo = new MongoDbRepository(new MongoDbRepositorySettings(mongoUri, path, "Users")); - IRepository groupRepo = new MongoDbRepository(new MongoDbRepositorySettings(mongoUri, path, "Groups")); + var MongoDatabaseName = path; + var MongoConnectionString = "mongodb://localhost:27017"; + IRepository userRepo = AXOpen.Data.MongoDb.Repository.Factory(new MongoDbRepositorySettings(MongoConnectionString, MongoDatabaseName, "Users", idExpression: t => t.Id)); + IRepository groupRepo = AXOpen.Data.MongoDb.Repository.Factory(new MongoDbRepositorySettings(MongoConnectionString, MongoDatabaseName, "Groups")); return (userRepo, groupRepo); }