Skip to content

Use of correction authentication properties #343

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/apps/Synapse.Worker/Services/Processors/FunctionProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,15 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
};
}
this.Authentication = auth;
if (this.Authentication != null) this.Authorization = await AuthorizationInfo.CreateAsync(this.ServiceProvider, this.Authentication, cancellationToken);
if (this.Authentication != null)
{
this.Authorization = await AuthorizationInfo.CreateAsync(this.ServiceProvider, this.Authentication, cancellationToken);
}
}
else
{
throw new NullReferenceException($"Failed to find the authentication definition with name '{this.Function.AuthRef}'");
}
}
}

Expand All @@ -109,7 +114,10 @@ protected override async Task OnNextAsync(IV1WorkflowActivityIntegrationEvent e,
if (e is V1WorkflowActivityCompletedIntegrationEvent completedEvent)
{
var output = completedEvent.Output.ToObject();
if (this.Action.ActionDataFilter != null) output = await this.Context.FilterOutputAsync(this.Action, output!, this.Authorization, cancellationToken);
if (this.Action.ActionDataFilter != null)
{
output = await this.Context.FilterOutputAsync(this.Action, output!, this.Authorization, cancellationToken);
}
await base.OnNextAsync(new V1WorkflowActivityCompletedIntegrationEvent(this.Activity.Id, output), cancellationToken);
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

@namespace Synapse.Dashboard

@if(authentication != null)
@if (authentication != null)
{
<table class="table table-striped">
<tbody>
Expand All @@ -30,7 +30,7 @@
<td>
<select class="form-select bg-secondary text-white"
@onchange="async e => await OnAuthenticationSchemeChangedAsync(EnumHelper.Parse<AuthenticationScheme>((string)e.Value!))">
@foreach(var scheme in Enum.GetValues<AuthenticationScheme>())
@foreach (var scheme in Enum.GetValues<AuthenticationScheme>())
{
var schemeStr = @EnumHelper.Stringify(scheme);
<option value="@schemeStr" selected="@(authentication.Scheme == scheme)">@schemeStr</option>
Expand Down Expand Up @@ -59,13 +59,13 @@
</td>
</Header>
<Body>
@if(!useSecretBasedProperties)
@if (!useSecretBasedProperties)
{
<td colspan="3">
@switch (authentication.Scheme)
{
case AuthenticationScheme.Basic:
if(authentication.Properties is not BasicAuthenticationProperties basic)
if (authentication.Properties is not BasicAuthenticationProperties basic)
{
basic = new();
authentication.Properties = basic;
Expand All @@ -86,7 +86,7 @@
</table>
break;
case AuthenticationScheme.Bearer:
if(authentication.Properties is not BearerAuthenticationProperties bearer)
if (authentication.Properties is not BearerAuthenticationProperties bearer)
{
bearer = new();
authentication.Properties = bearer;
Expand All @@ -102,7 +102,7 @@
</table>
break;
case AuthenticationScheme.OAuth2:
if(authentication.Properties is not OAuth2AuthenticationProperties oauth2)
if (authentication.Properties is not OAuth2AuthenticationProperties oauth2)
{
oauth2 = new();
authentication.Properties = oauth2;
Expand Down Expand Up @@ -147,7 +147,7 @@
if (Authentication == null)
return;
this.useSecretBasedProperties = !useSecretBasedProperties;
if(!this.useSecretBasedProperties)
if (!this.useSecretBasedProperties)
return;
this.Authentication.SecretRef = "undefined";
await this.OnChange.InvokeAsync(this.Authentication);
Expand All @@ -166,7 +166,7 @@
{
AuthenticationScheme.Basic => new BasicAuthenticationProperties(),
AuthenticationScheme.Bearer => new BearerAuthenticationProperties(),
AuthenticationScheme.OAuth2 => new BearerAuthenticationProperties(),
AuthenticationScheme.OAuth2 => new OAuth2AuthenticationProperties(),
_ => throw new NotSupportedException($"The specified {nameof(AuthenticationScheme)} '{a.Scheme}' is not supported")
};
});
Expand Down