diff --git a/src/modules/Elsa.Identity/Features/IdentityFeature.cs b/src/modules/Elsa.Identity/Features/IdentityFeature.cs index 8c6535152..5675ac32e 100644 --- a/src/modules/Elsa.Identity/Features/IdentityFeature.cs +++ b/src/modules/Elsa.Identity/Features/IdentityFeature.cs @@ -10,6 +10,7 @@ using Elsa.Identity.Options; using Elsa.Identity.Providers; using Elsa.Identity.Services; using JetBrains.Annotations; +using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.Extensions.DependencyInjection; namespace Elsa.Identity.Features; @@ -107,8 +108,12 @@ public class IdentityFeature : FeatureBase /// /// Configures the feature to use . /// - public void UseAdminUserProvider() => UserProvider = sp => sp.GetRequiredService(); - + public void UseAdminUserProvider() + { + UserProvider = sp => sp.GetRequiredService(); + RoleProvider = sp => sp.GetRequiredService(); + } + /// /// Configures the feature to use . /// @@ -172,6 +177,7 @@ public class IdentityFeature : FeatureBase // Role providers. Services + .AddSingleton() .AddSingleton() .AddSingleton(); diff --git a/src/modules/Elsa.Identity/Providers/AdminRoleProvider.cs b/src/modules/Elsa.Identity/Providers/AdminRoleProvider.cs new file mode 100644 index 000000000..47e84455a --- /dev/null +++ b/src/modules/Elsa.Identity/Providers/AdminRoleProvider.cs @@ -0,0 +1,24 @@ +using Elsa.Identity.Contracts; +using Elsa.Identity.Entities; +using Elsa.Identity.Models; + +namespace Elsa.Identity.Providers; + +/// +/// Represents a role provider that always returns a single admin role. This is useful for development purposes. +/// +public class AdminRoleProvider : IRoleProvider +{ + /// + public ValueTask> FindManyAsync(RoleFilter filter, CancellationToken cancellationToken = default) + { + var adminRole = new Role + { + Id = "admin", + Name = "admin", + Permissions = { "*" } + }; + + return new(new[] { adminRole }); + } +} \ No newline at end of file