Skip to content

Commit 9b82f60

Browse files
committed
Merge branch 'main' into fix-dashboard-misc
2 parents 8c1be5b + bbc82e9 commit 9b82f60

File tree

47 files changed

+168
-71
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+168
-71
lines changed

src/api/Synapse.Api.Application/Commands/Resources/CreateResourceCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ public class CreateResourceCommandHandler(IResourceRepository repository)
7979
/// <inheritdoc/>
8080
public virtual async Task<IOperationResult<IResource>> HandleAsync(CreateResourceCommand command, CancellationToken cancellationToken)
8181
{
82-
if (command.Resource.GetName().Trim().EndsWith('-')) command.Resource.Metadata.Name = $"{command.Resource.GetName().Trim()}{Guid.NewGuid().ToString("N")[..15]}";
82+
if (command.Resource.GetName().Trim().EndsWith('-')) command.Resource.Metadata.Name = $"{command.Resource.GetName().Trim()}{Guid.NewGuid().ToString("N")[..12]}";
8383
var resource = await repository.AddAsync(command.Resource, command.Group, command.Version, command.Plural, command.DryRun, cancellationToken);
8484
return new OperationResult<IResource>((int)HttpStatusCode.Created, resource);
8585
}

src/api/Synapse.Api.Application/Commands/Resources/Generic/CreateResourceCommand.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public class CreateResourceCommandHandler<TResource>(IResourceRepository reposit
4646
/// <inheritdoc/>
4747
public virtual async Task<IOperationResult<TResource>> HandleAsync(CreateResourceCommand<TResource> command, CancellationToken cancellationToken)
4848
{
49-
if (command.Resource.GetName().Trim().EndsWith('-')) command.Resource.Metadata.Name = $"{command.Resource.GetName().Trim()}{Guid.NewGuid().ToString("N")[..15]}";
49+
if (command.Resource.GetName().Trim().EndsWith('-')) command.Resource.Metadata.Name = $"{command.Resource.GetName().Trim()}{Guid.NewGuid().ToString("N")[..12]}";
5050
var resource = await repository.AddAsync(command.Resource, false, cancellationToken).ConfigureAwait(false);
5151
return new OperationResult<TResource>((int)HttpStatusCode.Created, resource);
5252
}

src/api/Synapse.Api.Application/Synapse.Api.Application.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha1</VersionSuffix>
10+
<VersionSuffix>alpha2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/api/Synapse.Api.Client.Core/Synapse.Api.Client.Core.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha1</VersionSuffix>
10+
<VersionSuffix>alpha2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/api/Synapse.Api.Client.Http/Synapse.Api.Client.Http.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha1</VersionSuffix>
10+
<VersionSuffix>alpha2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/api/Synapse.Api.Http/Synapse.Api.Http.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<OutputType>Library</OutputType>
99
<GenerateDocumentationFile>True</GenerateDocumentationFile>
1010
<VersionPrefix>1.0.0</VersionPrefix>
11-
<VersionSuffix>alpha1</VersionSuffix>
11+
<VersionSuffix>alpha2</VersionSuffix>
1212
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1313
<FileVersion>$(VersionPrefix)</FileVersion>
1414
<Authors>The Synapse Authors</Authors>

src/api/Synapse.Api.Server/Synapse.Api.Server.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha1</VersionSuffix>
10+
<VersionSuffix>alpha2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/cli/Synapse.Cli/Synapse.Cli.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<NeutralLanguage>en</NeutralLanguage>
99
<GenerateDocumentationFile>True</GenerateDocumentationFile>
1010
<VersionPrefix>1.0.0</VersionPrefix>
11-
<VersionSuffix>alpha1</VersionSuffix>
11+
<VersionSuffix>alpha2</VersionSuffix>
1212
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1313
<FileVersion>$(VersionPrefix)</FileVersion>
1414
<Authors>The Synapse Authors</Authors>

src/core/Synapse.Core.Infrastructure.Containers.Docker/DockerContainerPlatform.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ public virtual async Task<IContainer> CreateAsync(ContainerProcessDefinition def
9393
}
9494
var parameters = new CreateContainerParameters()
9595
{
96+
Name = $"{System.Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runner.Name)}-{definition.Image}-{Guid.NewGuid().ToString("N")[..6].ToLowerInvariant()}",
9697
Image = definition.Image,
9798
Cmd = string.IsNullOrWhiteSpace(definition.Command) ? null : ["/bin/sh", "-c", definition.Command],
9899
Env = definition.Environment?.Select(e => $"{e.Key}={e.Value}").ToList(),

src/core/Synapse.Core.Infrastructure.Containers.Docker/Synapse.Core.Infrastructure.Containers.Docker.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha1</VersionSuffix>
10+
<VersionSuffix>alpha2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/core/Synapse.Core.Infrastructure.Containers.Kubernetes/KubernetesContainer.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,10 +107,10 @@ protected virtual async Task WaitForReadyAsync(CancellationToken cancellationTok
107107
/// <inheritdoc/>
108108
public virtual async Task WaitForExitAsync(CancellationToken cancellationToken = default)
109109
{
110-
var response = this.Kubernetes.CoreV1.ListNamespacedPodWithHttpMessagesAsync(this.Pod.Namespace(), fieldSelector: $"metadata.name={Pod.Name()}", cancellationToken: cancellationToken);
110+
var response = this.Kubernetes.CoreV1.ListNamespacedPodWithHttpMessagesAsync(this.Pod.Namespace(), fieldSelector: $"metadata.name={Pod.Name()}", watch: true, cancellationToken: cancellationToken);
111111
await foreach (var (_, item) in response.WatchAsync<V1Pod, V1PodList>(cancellationToken: cancellationToken).ConfigureAwait(false))
112112
{
113-
if (item.Status.Phase != "Succeeded" || item.Status.Phase != "Failed") continue;
113+
if (item.Status.Phase != "Succeeded" && item.Status.Phase != "Failed") continue;
114114
var containerStatus = item.Status.ContainerStatuses.FirstOrDefault();
115115
this.ExitCode = containerStatus?.State.Terminated?.ExitCode ?? -1;
116116
break;

src/core/Synapse.Core.Infrastructure.Containers.Kubernetes/KubernetesContainerPlatform.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,17 +77,22 @@ public virtual Task<IContainer> CreateAsync(ContainerProcessDefinition definitio
7777
if (this.Kubernetes == null) throw new NullReferenceException("The KubernetesContainerPlatform has not been properly initialized");
7878
var pod = new V1Pod()
7979
{
80+
Metadata = new()
81+
{
82+
NamespaceProperty = $"{System.Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runner.Namespace)}",
83+
Name = $"{System.Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runner.Name)}-{definition.Image}-{Guid.NewGuid().ToString("N")[..6].ToLowerInvariant()}"
84+
},
8085
Spec = new()
8186
{
87+
RestartPolicy = "Never",
8288
Containers =
8389
[
84-
new()
90+
new(definition.Image)
8591
{
8692
Image = definition.Image,
8793
ImagePullPolicy = this.Options.ImagePullPolicy,
8894
Command = string.IsNullOrWhiteSpace(definition.Command) ? null : ["/bin/sh", "-c", definition.Command],
89-
Env = definition.Environment?.Select(e => new V1EnvVar(e.Key, e.Value)).ToList(),
90-
RestartPolicy = "Never"
95+
Env = definition.Environment?.Select(e => new V1EnvVar(e.Key, e.Value)).ToList()
9196
}
9297
]
9398
}

src/core/Synapse.Core.Infrastructure.Containers.Kubernetes/Synapse.Core.Infrastructure.Containers.Kubernetes.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha1</VersionSuffix>
10+
<VersionSuffix>alpha2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/core/Synapse.Core.Infrastructure/Synapse.Core.Infrastructure.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha1</VersionSuffix>
10+
<VersionSuffix>alpha2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/core/Synapse.Core/Events/Workflows/WorkflowCompletedEventV1.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,10 @@ public record WorkflowCompletedEventV1
3232
[DataMember(Name = "completedAt", Order = 2), JsonPropertyName("completedAt"), JsonPropertyOrder(2), YamlMember(Alias = "completedAt", Order = 2)]
3333
public DateTimeOffset CompletedAt { get; set; } = DateTimeOffset.Now;
3434

35+
/// <summary>
36+
/// Gets/sets the workflow instance's output
37+
/// </summary>
38+
[DataMember(Name = "output", Order = 3), JsonPropertyName("output"), JsonPropertyOrder(3), YamlMember(Alias = "output", Order = 3)]
39+
public object? Output { get; set; }
40+
3541
}

src/core/Synapse.Core/Resources/Document.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public record Document
2323

2424
/// <inheritdoc/>
2525
[DataMember(Name = "id", Order = 1), JsonPropertyName("id"), JsonPropertyOrder(1), YamlMember(Alias = "id", Order = 1)]
26-
public string Id { get; set; } = Guid.NewGuid().ToString("N")[..15];
26+
public string Id { get; set; } = Guid.NewGuid().ToString("N")[..12];
2727

2828
/// <summary>
2929
/// Gets/sets the document's name

src/core/Synapse.Core/Resources/NativeRuntimeConfiguration.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,10 @@ public record NativeRuntimeConfiguration
2828
/// Gets the default path to the runner executable file
2929
/// </summary>
3030
public const string DefaultExecutable = "Synapse.Runner";
31+
/// <summary>
32+
/// Gets the default path to the directory that contains the secrets made available to runners
33+
/// </summary>
34+
public static readonly string DefaultSecretsDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), ".synapse", "secrets");
3135

3236
/// <summary>
3337
/// Initializes a new <see cref="NativeRuntimeConfiguration"/>
@@ -47,6 +51,8 @@ public NativeRuntimeConfiguration()
4751
if (!File.Exists(filePath)) throw new FileNotFoundException("The runner executable file does not exist or cannot be found", filePath);
4852
this.Executable = env;
4953
}
54+
env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Runtime.Native.SecretsDirectory);
55+
if (!string.IsNullOrWhiteSpace(env)) this.SecretsDirectory = env;
5056
}
5157

5258
/// <summary>
@@ -61,5 +67,10 @@ public NativeRuntimeConfiguration()
6167
[DataMember(Order = 2, Name = "executable"), JsonPropertyOrder(2), JsonPropertyName("executable"), YamlMember(Order = 2, Alias = "executable")]
6268
public virtual string Executable { get; set; } = DefaultExecutable;
6369

70+
/// <summary>
71+
/// Gets/sets the path to the directory that contains the secrets made available to runners
72+
/// </summary>
73+
[DataMember(Order = 3, Name = "secretsDirectory"), JsonPropertyOrder(3), JsonPropertyName("secretsDirectory"), YamlMember(Order = 3, Alias = "secretsDirectory")]
74+
public virtual string SecretsDirectory { get; set; } = DefaultSecretsDirectory;
6475

6576
}

src/core/Synapse.Core/Resources/TaskInstance.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public record TaskInstance
2424
/// Gets the task's id
2525
/// </summary>
2626
[DataMember(Name = "id", Order = 1), JsonPropertyName("id"), JsonPropertyOrder(1), YamlMember(Alias = "id", Order = 1)]
27-
public virtual string Id { get; set; } = Guid.NewGuid().ToString("N")[..15];
27+
public virtual string Id { get; set; } = Guid.NewGuid().ToString("N")[..12];
2828

2929
/// <summary>
3030
/// Gets the task's name, if any

src/core/Synapse.Core/Synapse.Core.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@
77
<NeutralLanguage>en</NeutralLanguage>
88
<GenerateDocumentationFile>True</GenerateDocumentationFile>
99
<VersionPrefix>1.0.0</VersionPrefix>
10-
<VersionSuffix>alpha1</VersionSuffix>
10+
<VersionSuffix>alpha2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>
1414
<Company>Cloud Native Computing Foundation</Company>
1515
<Copyright>Copyright © 2024-Present The Synapse Authors. All Rights Reserved.</Copyright>
1616
<RepositoryUrl>https://github.com/serverlessworkflow/synapse</RepositoryUrl>
1717
<RepositoryType>git</RepositoryType>
18+
<PackageId>Synapse</PackageId>
1819
<PackageProjectUrl>https://github.com/serverlessworkflow/synapse</PackageProjectUrl>
1920
<PackageTags>synapse core</PackageTags>
2021
<IsPackable>true</IsPackable>

src/core/Synapse.Core/SynapseDefaults.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
using Synapse.Resources;
1514
using Neuroglia.Data.Infrastructure.ResourceOriented;
15+
using Synapse.Resources;
1616
using System.Diagnostics;
1717
using System.Reflection;
1818

@@ -562,6 +562,14 @@ public static class Runner
562562
/// Gets the environment variable used to configure whether or not runners should publish lifecycle events
563563
/// </summary>
564564
public const string LifecycleEvents = Prefix + "LIFECYCLE_EVENTS";
565+
/// <summary>
566+
/// Gets the environment variable used to configure the runner's namespace
567+
/// </summary>
568+
public const string Namespace = Prefix + "NAMESPACE";
569+
/// <summary>
570+
/// Gets the environment variable used to configure the runner's name
571+
/// </summary>
572+
public const string Name = Prefix + "NAME";
565573

566574
}
567575

@@ -740,6 +748,10 @@ public static class Native
740748
/// Gets the environment variable used to configure the path to the runner's executable file
741749
/// </summary>
742750
public const string Executable = Prefix + "EXECUTABLE";
751+
/// <summary>
752+
/// Gets the environment variable used to configure the directory that contains the secrets made available to runners
753+
/// </summary>
754+
public const string SecretsDirectory = Prefix + "SECRETS_DIRECTORY";
743755

744756
}
745757

@@ -754,7 +766,7 @@ public static class Secrets
754766
/// <summary>
755767
/// Gets the prefix for all secrets related environment variables
756768
/// </summary>
757-
public const string Prefix = EnvironmentVariables.Prefix + "SECRETS";
769+
public const string Prefix = EnvironmentVariables.Prefix + "SECRETS_";
758770
/// <summary>
759771
/// Gets the name of the environment variable used to configure the path to the directory that contains secrets files
760772
/// </summary>

src/correlator/Synapse.Correlator/Services/CorrelationHandler.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ protected virtual async Task CorrelateEventAsync(CloudEvent e, CancellationToken
121121
this.Logger.LogInformation("Creating a new correlation context...");
122122
context = new CorrelationContext()
123123
{
124-
Id = Guid.NewGuid().ToString("N")[..15],
124+
Id = Guid.NewGuid().ToString("N")[..12],
125125
Events = [new(filter.Key, e)],
126126
Keys = CorrelationKeys == null ? new() : new(CorrelationKeys)
127127
};
@@ -150,7 +150,7 @@ protected virtual async Task CorrelateEventAsync(CloudEvent e, CancellationToken
150150
this.Logger.LogInformation("Creating a new correlation context...");
151151
context = new CorrelationContext()
152152
{
153-
Id = Guid.NewGuid().ToString("N")[..15],
153+
Id = Guid.NewGuid().ToString("N")[..12],
154154
Events = [new(filter.Key, e)],
155155
Keys = CorrelationKeys == null ? new() : new(CorrelationKeys)
156156
};

src/correlator/Synapse.Correlator/Synapse.Correlator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<NeutralLanguage>en</NeutralLanguage>
99
<GenerateDocumentationFile>True</GenerateDocumentationFile>
1010
<VersionPrefix>1.0.0</VersionPrefix>
11-
<VersionSuffix>alpha1</VersionSuffix>
11+
<VersionSuffix>alpha2</VersionSuffix>
1212
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1313
<FileVersion>$(VersionPrefix)</FileVersion>
1414
<Authors>The Synapse Authors</Authors>

src/operator/Synapse.Operator/Synapse.Operator.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<NeutralLanguage>en</NeutralLanguage>
99
<GenerateDocumentationFile>True</GenerateDocumentationFile>
1010
<VersionPrefix>1.0.0</VersionPrefix>
11-
<VersionSuffix>alpha1</VersionSuffix>
11+
<VersionSuffix>alpha2</VersionSuffix>
1212
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1313
<FileVersion>$(VersionPrefix)</FileVersion>
1414
<Authors>The Synapse Authors</Authors>

src/runner/Synapse.Runner/AuthorizationInfo.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
// See the License for the specific language governing permissions and
1212
// limitations under the License.
1313

14-
using Docker.DotNet.Models;
1514
using Neuroglia.Data.Infrastructure.ResourceOriented;
1615
using ServerlessWorkflow.Sdk.Models.Authentication;
1716
using System.Text;
@@ -42,16 +41,22 @@ public class AuthorizationInfo(string scheme, string parameter)
4241
/// <summary>
4342
/// Creates a new <see cref="AuthorizationInfo"/> based on the specified <see cref="AuthenticationPolicyDefinition"/>
4443
/// </summary>
44+
/// <param name="workflow">The <see cref="WorkflowDefinition"/> that defines the <see cref="AuthenticationPolicyDefinition"/> to create a new <see cref="AuthorizationInfo"/> for</param>
4545
/// <param name="authentication">The <see cref="AuthenticationPolicyDefinition"/> to create a new <see cref="AuthorizationInfo"/> for</param>
4646
/// <param name="serviceProvider">The current <see cref="IServiceProvider"/></param>
4747
/// <param name="cancellationToken">A <see cref="CancellationToken"/></param>
4848
/// <returns>A new <see cref="AuthorizationInfo"/> based on the specified <see cref="AuthenticationPolicyDefinition"/></returns>
49-
public static async Task<AuthorizationInfo> CreateAsync(AuthenticationPolicyDefinition authentication, IServiceProvider serviceProvider, CancellationToken cancellationToken = default)
49+
public static async Task<AuthorizationInfo> CreateAsync(WorkflowDefinition workflow, AuthenticationPolicyDefinition authentication, IServiceProvider serviceProvider, CancellationToken cancellationToken = default)
5050
{
5151
ArgumentNullException.ThrowIfNull(nameof(authentication));
5252
ArgumentNullException.ThrowIfNull(nameof(serviceProvider));
5353
string scheme, parameter;
5454
var logger = serviceProvider.GetRequiredService<ILoggerFactory>().CreateLogger("AuthenticationPolicyHandler");
55+
if (!string.IsNullOrWhiteSpace(authentication.Use))
56+
{
57+
if (workflow.Use?.Authentications?.TryGetValue(authentication.Use, out AuthenticationPolicyDefinition? referencedAuthentication) != true || referencedAuthentication == null) throw new NullReferenceException($"Failed to find the specified authentication policy '{authentication.Use}'");
58+
else authentication = referencedAuthentication;
59+
}
5560
var isSecretBased = authentication.TryGetBaseSecret(out var secretName);
5661
object? authenticationProperties = null;
5762
if (isSecretBased && !string.IsNullOrWhiteSpace(secretName))

0 commit comments

Comments
 (0)