Add missing AdminRoleProvider
This commit is contained in:
parent
bf810e7d7a
commit
ded2966416
|
|
@ -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
|
|||
/// <summary>
|
||||
/// Configures the feature to use <see cref="AdminUserProvider"/>.
|
||||
/// </summary>
|
||||
public void UseAdminUserProvider() => UserProvider = sp => sp.GetRequiredService<AdminUserProvider>();
|
||||
|
||||
public void UseAdminUserProvider()
|
||||
{
|
||||
UserProvider = sp => sp.GetRequiredService<AdminUserProvider>();
|
||||
RoleProvider = sp => sp.GetRequiredService<AdminRoleProvider>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Configures the feature to use <see cref="StoreBasedApplicationProvider"/>.
|
||||
/// </summary>
|
||||
|
|
@ -172,6 +177,7 @@ public class IdentityFeature : FeatureBase
|
|||
|
||||
// Role providers.
|
||||
Services
|
||||
.AddSingleton<AdminRoleProvider>()
|
||||
.AddSingleton<StoreBasedRoleProvider>()
|
||||
.AddSingleton<ConfigurationBasedRoleProvider>();
|
||||
|
||||
|
|
|
|||
24
src/modules/Elsa.Identity/Providers/AdminRoleProvider.cs
Normal file
24
src/modules/Elsa.Identity/Providers/AdminRoleProvider.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using Elsa.Identity.Contracts;
|
||||
using Elsa.Identity.Entities;
|
||||
using Elsa.Identity.Models;
|
||||
|
||||
namespace Elsa.Identity.Providers;
|
||||
|
||||
/// <summary>
|
||||
/// Represents a role provider that always returns a single admin role. This is useful for development purposes.
|
||||
/// </summary>
|
||||
public class AdminRoleProvider : IRoleProvider
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public ValueTask<IEnumerable<Role>> FindManyAsync(RoleFilter filter, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var adminRole = new Role
|
||||
{
|
||||
Id = "admin",
|
||||
Name = "admin",
|
||||
Permissions = { "*" }
|
||||
};
|
||||
|
||||
return new(new[] { adminRole });
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue