| | | 1 | | using Elsa.Abstractions; |
| | | 2 | | using Elsa.ExternalAuthentication.Contracts; |
| | | 3 | | using Elsa.ExternalAuthentication.Models; |
| | | 4 | | using Elsa.ExternalAuthentication.Options; |
| | | 5 | | using Elsa.ExternalAuthentication.Permissions; |
| | | 6 | | using Microsoft.Extensions.Options; |
| | | 7 | | |
| | | 8 | | namespace Elsa.ExternalAuthentication.Endpoints.Descriptors; |
| | | 9 | | |
| | | 10 | | /// <summary>Publishes only startup-installed, deployment-allowed extension metadata for generic management editors.</su |
| | | 11 | | internal sealed class ListAdapterDescriptors(IExternalAuthenticationAdapterRegistry registry, IOptions<ExternalAuthentic |
| | | 12 | | { |
| | | 13 | | public override void Configure() |
| | | 14 | | { |
| | | 15 | | Get("/external-authentication/descriptors/adapters"); |
| | | 16 | | ConfigurePermissions(ExternalAuthenticationPermissions.ConnectionsRead); |
| | | 17 | | } |
| | | 18 | | |
| | | 19 | | public override Task<IReadOnlyCollection<ExternalAuthenticationAdapterDescriptor>> ExecuteAsync(CancellationToken ca |
| | | 20 | | { |
| | | 21 | | var allowed = options.Value.AllowedAdapterTypes; |
| | | 22 | | IReadOnlyCollection<ExternalAuthenticationAdapterDescriptor> response = registry.ListDescriptors() |
| | | 23 | | .Where(x => allowed.Count == 0 || allowed.Contains(x.Type, StringComparer.Ordinal)) |
| | | 24 | | .OrderBy(x => x.Type, StringComparer.Ordinal) |
| | | 25 | | .ToArray(); |
| | | 26 | | return Task.FromResult(response); |
| | | 27 | | } |
| | | 28 | | } |
| | | 29 | | |
| | | 30 | | internal sealed class ListPolicyDescriptors(IUnlinkedIdentityPolicyRegistry registry) : ElsaEndpointWithoutRequest<IRead |
| | | 31 | | { |
| | | 32 | | public override void Configure() |
| | | 33 | | { |
| | | 34 | | Get("/external-authentication/descriptors/policies"); |
| | | 35 | | ConfigurePermissions(ExternalAuthenticationPermissions.ConnectionsRead); |
| | | 36 | | } |
| | | 37 | | |
| | | 38 | | public override Task<IReadOnlyCollection<UnlinkedIdentityPolicyDescriptor>> ExecuteAsync(CancellationToken cancellat |
| | | 39 | | { |
| | | 40 | | return Task.FromResult(registry.ListDescriptors()); |
| | | 41 | | } |
| | | 42 | | } |
| | | 43 | | |
| | 0 | 44 | | internal sealed class ListPermissionSourceDescriptors(IPermissionGrantSourceRegistry registry) : ElsaEndpointWithoutRequ |
| | | 45 | | { |
| | | 46 | | public override void Configure() |
| | | 47 | | { |
| | 0 | 48 | | Get("/external-authentication/descriptors/permission-sources"); |
| | 0 | 49 | | ConfigurePermissions(ExternalAuthenticationPermissions.ConnectionsRead); |
| | 0 | 50 | | } |
| | | 51 | | |
| | | 52 | | public override Task<IReadOnlyCollection<PermissionGrantSourceDescriptor>> ExecuteAsync(CancellationToken cancellati |
| | | 53 | | { |
| | 0 | 54 | | return Task.FromResult(registry.ListDescriptors()); |
| | | 55 | | } |
| | | 56 | | } |
| | | 57 | | |
| | | 58 | | internal sealed class ListExternalUserMatcherDescriptors(IExternalUserMatcherRegistry registry) : ElsaEndpointWithoutReq |
| | | 59 | | { |
| | | 60 | | public override void Configure() |
| | | 61 | | { |
| | | 62 | | Get("/external-authentication/descriptors/user-matchers"); |
| | | 63 | | ConfigurePermissions(ExternalAuthenticationPermissions.ConnectionsRead); |
| | | 64 | | } |
| | | 65 | | |
| | | 66 | | public override Task<IReadOnlyCollection<ExternalUserMatcherDescriptor>> ExecuteAsync(CancellationToken cancellation |
| | | 67 | | } |
| | | 68 | | |
| | | 69 | | internal sealed record ManagedSecretResolverDescriptor(string Type, string DisplayName); |
| | | 70 | | internal sealed record ManagedSecretResolverDescriptorResponse(IReadOnlyCollection<ManagedSecretResolverDescriptor> Item |
| | | 71 | | |
| | | 72 | | /// <summary>Lists installed managed secret writers without revealing any bound secret reference.</summary> |
| | | 73 | | internal sealed class ListManagedSecretResolverDescriptors(IEnumerable<IManagedSecretBindingWriter> writers) : ElsaEndpo |
| | | 74 | | { |
| | | 75 | | public override void Configure() |
| | | 76 | | { |
| | | 77 | | Get("/external-authentication/descriptors/managed-secret-resolvers"); |
| | | 78 | | ConfigurePermissions(ExternalAuthenticationPermissions.ConnectionsRead); |
| | | 79 | | } |
| | | 80 | | |
| | | 81 | | public override Task<ManagedSecretResolverDescriptorResponse> ExecuteAsync(CancellationToken cancellationToken) => T |
| | | 82 | | writers.Select(x => new ManagedSecretResolverDescriptor(x.ResolverType, x.DisplayName)).OrderBy(x => x.Type, Str |
| | | 83 | | } |
| | | 84 | | |
| | | 85 | | internal sealed class ListPermissionDescriptors(IPermissionDescriptorRegistry registry) : ElsaEndpointWithoutRequest<IRe |
| | | 86 | | { |
| | | 87 | | public override void Configure() |
| | | 88 | | { |
| | | 89 | | Get("/external-authentication/descriptors/permissions"); |
| | | 90 | | ConfigurePermissions(ExternalAuthenticationPermissions.ConnectionsRead); |
| | | 91 | | } |
| | | 92 | | |
| | | 93 | | public override Task<IReadOnlyCollection<PermissionDescriptor>> ExecuteAsync(CancellationToken cancellationToken) => |
| | | 94 | | } |