< Summary

Information
Class: Elsa.ExternalAuthentication.Endpoints.Descriptors.ListPermissionDescriptors
Assembly: Elsa.ExternalAuthentication
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.ExternalAuthentication/Endpoints/Descriptors/DescriptorCatalogEndpoints.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 5
Coverable lines: 5
Total lines: 103
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
Configure()100%210%
ExecuteAsync(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.ExternalAuthentication/Endpoints/Descriptors/DescriptorCatalogEndpoints.cs

#LineLine coverage
 1using Elsa.Authorization;
 2using Elsa.Abstractions;
 3using Elsa.Permissions;
 4using Elsa.ExternalAuthentication.Contracts;
 5using Elsa.ExternalAuthentication.Models;
 6using Elsa.ExternalAuthentication.Options;
 7using Microsoft.Extensions.Options;
 8
 9namespace Elsa.ExternalAuthentication.Endpoints.Descriptors;
 10
 11/// <summary>Publishes only startup-installed, deployment-allowed extension metadata for generic management editors.</su
 12internal sealed class ListAdapterDescriptors(IExternalAuthenticationAdapterRegistry registry, IOptions<ExternalAuthentic
 13{
 14    public override void Configure()
 15    {
 16        Get("/external-authentication/descriptors/adapters");
 17        RequirePermission(ExternalAuthentication.Permissions.ExternalAuthenticationResourcePermissions.Connections, Core
 18    }
 19
 20    public override Task<IReadOnlyCollection<ExternalAuthenticationAdapterDescriptor>> ExecuteAsync(CancellationToken ca
 21    {
 22        var allowed = options.Value.AllowedAdapterTypes;
 23        IReadOnlyCollection<ExternalAuthenticationAdapterDescriptor> response = registry.ListDescriptors()
 24            .Where(x => allowed.Count == 0 || allowed.Contains(x.Type, StringComparer.Ordinal))
 25            .OrderBy(x => x.Type, StringComparer.Ordinal)
 26            .ToArray();
 27        return Task.FromResult(response);
 28    }
 29}
 30
 31internal sealed class ListPolicyDescriptors(IUnlinkedIdentityPolicyRegistry registry) : ElsaEndpointWithoutRequest<IRead
 32{
 33    public override void Configure()
 34    {
 35        Get("/external-authentication/descriptors/policies");
 36        RequirePermission(ExternalAuthentication.Permissions.ExternalAuthenticationResourcePermissions.Connections, Core
 37    }
 38
 39    public override Task<IReadOnlyCollection<UnlinkedIdentityPolicyDescriptor>> ExecuteAsync(CancellationToken cancellat
 40    {
 41        return Task.FromResult(registry.ListDescriptors());
 42    }
 43}
 44
 45internal sealed class ListPermissionSourceDescriptors(IPermissionGrantSourceRegistry registry) : ElsaEndpointWithoutRequ
 46{
 47    public override void Configure()
 48    {
 49        Get("/external-authentication/descriptors/permission-sources");
 50        RequirePermission(ExternalAuthentication.Permissions.ExternalAuthenticationResourcePermissions.Connections, Core
 51    }
 52
 53    public override Task<IReadOnlyCollection<PermissionGrantSourceDescriptor>> ExecuteAsync(CancellationToken cancellati
 54    {
 55        return Task.FromResult(registry.ListDescriptors());
 56    }
 57}
 58
 59internal sealed class ListExternalUserMatcherDescriptors(IExternalUserMatcherRegistry registry) : ElsaEndpointWithoutReq
 60{
 61    public override void Configure()
 62    {
 63        Get("/external-authentication/descriptors/user-matchers");
 64        RequirePermission(ExternalAuthentication.Permissions.ExternalAuthenticationResourcePermissions.Connections, Core
 65    }
 66
 67    public override Task<IReadOnlyCollection<ExternalUserMatcherDescriptor>> ExecuteAsync(CancellationToken cancellation
 68}
 69
 70internal sealed record ManagedSecretResolverDescriptor(string Type, string DisplayName);
 71internal sealed record ManagedSecretResolverDescriptorResponse(IReadOnlyCollection<ManagedSecretResolverDescriptor> Item
 72
 73/// <summary>Lists installed managed secret writers without revealing any bound secret reference.</summary>
 74internal sealed class ListManagedSecretResolverDescriptors(IEnumerable<IManagedSecretBindingWriter> writers) : ElsaEndpo
 75{
 76    public override void Configure()
 77    {
 78        Get("/external-authentication/descriptors/managed-secret-resolvers");
 79        RequirePermission(ExternalAuthentication.Permissions.ExternalAuthenticationResourcePermissions.Connections, Core
 80    }
 81
 82    public override Task<ManagedSecretResolverDescriptorResponse> ExecuteAsync(CancellationToken cancellationToken) => T
 83        writers.Select(x => new ManagedSecretResolverDescriptor(x.ResolverType, x.DisplayName)).OrderBy(x => x.Type, Str
 84}
 85
 86/// <summary>
 87/// Lists the permissions a claim mapping may be configured to confer.
 88/// </summary>
 89/// <remarks>
 90/// This serves the core catalog rather than a registry private to this module. Choosing what an external
 91/// mapping confers means choosing from everything Elsa declares, not just from this module's own resources,
 92/// and the module's registry only ever held its legacy permission names anyway.
 93/// </remarks>
 094internal sealed class ListPermissionDescriptors(IPermissionDescriptorRegistry registry) : ElsaEndpointWithoutRequest<IRe
 95{
 96    public override void Configure()
 97    {
 098        Get("/external-authentication/descriptors/permissions");
 099        RequirePermission(ExternalAuthentication.Permissions.ExternalAuthenticationResourcePermissions.Connections, Core
 0100    }
 101
 0102    public override Task<IReadOnlyCollection<PermissionDescriptor>> ExecuteAsync(CancellationToken cancellationToken) =>
 103}