Skip to content

Commit bb4d95b

Browse files
authored
Merge pull request #343 from jaliyaudagedara/fix/use-of-correction-authentication-properties
fix(Worker/Dashboard): Use of correction authentication properties
2 parents b3c07d5 + 551acd6 commit bb4d95b

File tree

2 files changed

+18
-10
lines changed

2 files changed

+18
-10
lines changed

src/apps/Synapse.Worker/Services/Processors/FunctionProcessor.cs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,15 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
9393
};
9494
}
9595
this.Authentication = auth;
96-
if (this.Authentication != null) this.Authorization = await AuthorizationInfo.CreateAsync(this.ServiceProvider, this.Authentication, cancellationToken);
96+
if (this.Authentication != null)
97+
{
98+
this.Authorization = await AuthorizationInfo.CreateAsync(this.ServiceProvider, this.Authentication, cancellationToken);
99+
}
97100
}
98101
else
102+
{
99103
throw new NullReferenceException($"Failed to find the authentication definition with name '{this.Function.AuthRef}'");
104+
}
100105
}
101106
}
102107

@@ -106,7 +111,10 @@ protected override async Task OnNextAsync(IV1WorkflowActivityIntegrationEvent e,
106111
if (e is V1WorkflowActivityCompletedIntegrationEvent completedEvent)
107112
{
108113
var output = completedEvent.Output.ToObject();
109-
if (this.Action.ActionDataFilter != null) output = await this.Context.FilterOutputAsync(this.Action, output!, this.Authorization, cancellationToken);
114+
if (this.Action.ActionDataFilter != null)
115+
{
116+
output = await this.Context.FilterOutputAsync(this.Action, output!, this.Authorization, cancellationToken);
117+
}
110118
await base.OnNextAsync(new V1WorkflowActivityCompletedIntegrationEvent(this.Activity.Id, output), cancellationToken);
111119
}
112120
else

src/dashboard/Synapse.Dashboard/Features/Workflows/WorkflowEditor/AuthenticationEditor.razor

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
@namespace Synapse.Dashboard
1818

19-
@if(authentication != null)
19+
@if (authentication != null)
2020
{
2121
<table class="table table-striped">
2222
<tbody>
@@ -30,7 +30,7 @@
3030
<td>
3131
<select class="form-select bg-secondary text-white"
3232
@onchange="async e => await OnAuthenticationSchemeChangedAsync(EnumHelper.Parse<AuthenticationScheme>((string)e.Value!))">
33-
@foreach(var scheme in Enum.GetValues<AuthenticationScheme>())
33+
@foreach (var scheme in Enum.GetValues<AuthenticationScheme>())
3434
{
3535
var schemeStr = @EnumHelper.Stringify(scheme);
3636
<option value="@schemeStr" selected="@(authentication.Scheme == scheme)">@schemeStr</option>
@@ -59,13 +59,13 @@
5959
</td>
6060
</Header>
6161
<Body>
62-
@if(!useSecretBasedProperties)
62+
@if (!useSecretBasedProperties)
6363
{
6464
<td colspan="3">
6565
@switch (authentication.Scheme)
6666
{
6767
case AuthenticationScheme.Basic:
68-
if(authentication.Properties is not BasicAuthenticationProperties basic)
68+
if (authentication.Properties is not BasicAuthenticationProperties basic)
6969
{
7070
basic = new();
7171
authentication.Properties = basic;
@@ -86,7 +86,7 @@
8686
</table>
8787
break;
8888
case AuthenticationScheme.Bearer:
89-
if(authentication.Properties is not BearerAuthenticationProperties bearer)
89+
if (authentication.Properties is not BearerAuthenticationProperties bearer)
9090
{
9191
bearer = new();
9292
authentication.Properties = bearer;
@@ -102,7 +102,7 @@
102102
</table>
103103
break;
104104
case AuthenticationScheme.OAuth2:
105-
if(authentication.Properties is not OAuth2AuthenticationProperties oauth2)
105+
if (authentication.Properties is not OAuth2AuthenticationProperties oauth2)
106106
{
107107
oauth2 = new();
108108
authentication.Properties = oauth2;
@@ -147,7 +147,7 @@
147147
if (Authentication == null)
148148
return;
149149
this.useSecretBasedProperties = !useSecretBasedProperties;
150-
if(!this.useSecretBasedProperties)
150+
if (!this.useSecretBasedProperties)
151151
return;
152152
this.Authentication.SecretRef = "undefined";
153153
await this.OnChange.InvokeAsync(this.Authentication);
@@ -166,7 +166,7 @@
166166
{
167167
AuthenticationScheme.Basic => new BasicAuthenticationProperties(),
168168
AuthenticationScheme.Bearer => new BearerAuthenticationProperties(),
169-
AuthenticationScheme.OAuth2 => new BearerAuthenticationProperties(),
169+
AuthenticationScheme.OAuth2 => new OAuth2AuthenticationProperties(),
170170
_ => throw new NotSupportedException($"The specified {nameof(AuthenticationScheme)} '{a.Scheme}' is not supported")
171171
};
172172
});

0 commit comments

Comments
 (0)