Skip to content

Commit 288dd84

Browse files
authored
Merge pull request #426 from serverlessworkflow/fix-runner-jwt-issuer-validation
Fixed the `OAuth2TokenManager` to not validate access token issuer name
2 parents a611bcb + ed9c5b9 commit 288dd84

File tree

23 files changed

+60
-26
lines changed

23 files changed

+60
-26
lines changed

src/api/Synapse.Api.Application/Configuration/AuthenticationPolicyOptions.cs

+19
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,25 @@ public AuthenticationPolicyOptions()
4545
this.Jwt ??= new();
4646
this.Jwt.Audience = env;
4747
}
48+
env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Api.Authentication.Jwt.SigningKey);
49+
if (!string.IsNullOrWhiteSpace(env))
50+
{
51+
this.Jwt ??= new();
52+
this.Jwt.SigningKey = env;
53+
}
54+
env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Api.Authentication.Jwt.Issuer);
55+
if (!string.IsNullOrWhiteSpace(env))
56+
{
57+
this.Jwt ??= new();
58+
this.Jwt.Issuer = env;
59+
}
60+
env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Api.Authentication.Jwt.ValidateIssuer);
61+
if (!string.IsNullOrWhiteSpace(env))
62+
{
63+
if (!bool.TryParse(env, out var validateIssuer)) throw new Exception($"Failed to parse the specified value '{env}' into a boolean");
64+
this.Jwt ??= new();
65+
this.Jwt.ValidateIssuer = validateIssuer;
66+
}
4867
env = Environment.GetEnvironmentVariable(SynapseDefaults.EnvironmentVariables.Api.Authentication.Oidc.Authority);
4968
if (!string.IsNullOrWhiteSpace(env))
5069
{

src/api/Synapse.Api.Application/Configuration/JwtBearerAuthenticationOptions.cs

+5
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public class JwtBearerAuthenticationOptions
4242
/// </summary>
4343
public virtual string? Issuer { get; set; }
4444

45+
/// <summary>
46+
/// Gets/sets a boolean indicating whether or not to validate the issuer of JWT tokens
47+
/// </summary>
48+
public virtual bool ValidateIssuer { get; set; } = true;
49+
4550
/// <summary>
4651
/// Gets the configured issuer signing key
4752
/// </summary>

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

+1-1
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>alpha3.1</VersionSuffix>
10+
<VersionSuffix>alpha3.2</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

+1-1
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>alpha3.1</VersionSuffix>
10+
<VersionSuffix>alpha3.2</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

+1-1
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>alpha3.1</VersionSuffix>
10+
<VersionSuffix>alpha3.2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

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

+1-1
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>alpha3.1</VersionSuffix>
11+
<VersionSuffix>alpha3.2</VersionSuffix>
1212
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1313
<FileVersion>$(VersionPrefix)</FileVersion>
1414
<Authors>The Synapse Authors</Authors>

src/api/Synapse.Api.Server/Program.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
ValidAudience = applicationOptions.Authentication.Jwt.Audience,
7676
ValidateAudience = !string.IsNullOrWhiteSpace(applicationOptions.Authentication.Jwt.Audience),
7777
ValidIssuer = applicationOptions.Authentication.Jwt.Issuer,
78-
ValidateIssuer = !string.IsNullOrWhiteSpace(applicationOptions.Authentication.Jwt.Issuer),
78+
ValidateIssuer = applicationOptions.Authentication.Jwt.ValidateIssuer,
7979
IssuerSigningKey = applicationOptions.Authentication.Jwt.GetSigningKey()
8080
};
8181
});

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

+1-1
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>alpha3.1</VersionSuffix>
10+
<VersionSuffix>alpha3.2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

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

+1-1
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>alpha3.1</VersionSuffix>
11+
<VersionSuffix>alpha3.2</VersionSuffix>
1212
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1313
<FileVersion>$(VersionPrefix)</FileVersion>
1414
<Authors>The Synapse Authors</Authors>

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

+1-1
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>alpha3.1</VersionSuffix>
10+
<VersionSuffix>alpha3.2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

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

+1-1
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>alpha3.1</VersionSuffix>
10+
<VersionSuffix>alpha3.2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

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

+1-1
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>alpha3.1</VersionSuffix>
10+
<VersionSuffix>alpha3.2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

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

+1-1
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>alpha3.1</VersionSuffix>
10+
<VersionSuffix>alpha3.2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/core/Synapse.Core/SynapseDefaults.cs

+15-3
Original file line numberDiff line numberDiff line change
@@ -440,18 +440,30 @@ public static class Jwt
440440
{
441441

442442
/// <summary>
443-
/// Gets the prefix for all JWT Bearer related environment variables
443+
/// Gets the prefix for all JWT related environment variables
444444
/// </summary>
445445
public const string Prefix = Authentication.Prefix + "JWT_";
446446

447447
/// <summary>
448-
/// Gets the name of the environment variables used to specify the JWT Bearer authority to use
448+
/// Gets the name of the environment variables used to specify the JWT authority to use
449449
/// </summary>
450450
public const string Authority = Prefix + "AUTHORITY";
451451
/// <summary>
452-
/// Gets the name of the environment variables used to specify the JWT Bearer audience
452+
/// Gets the name of the environment variables used to specify the JWT audience
453453
/// </summary>
454454
public const string Audience = Prefix + "AUDIENCE";
455+
/// <summary>
456+
/// Gets the name of the environment variables used to configure the key used to verify the signature of JWT tokens
457+
/// </summary>
458+
public const string SigningKey = Prefix + "SIGNING_KEY";
459+
/// <summary>
460+
/// Gets the name of the environment variables used to configure the expected issuer of JWT tokens
461+
/// </summary>
462+
public const string Issuer = Prefix + "ISSUER";
463+
/// <summary>
464+
/// Gets the name of the environment variables used to configure whether or not to validate the issuer of JWT tokens
465+
/// </summary>
466+
public const string ValidateIssuer = Prefix + "VALIDATE_ISSUER";
455467

456468
}
457469

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

+1-1
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>alpha3.1</VersionSuffix>
11+
<VersionSuffix>alpha3.2</VersionSuffix>
1212
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1313
<FileVersion>$(VersionPrefix)</FileVersion>
1414
<Authors>The Synapse Authors</Authors>

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

+1-1
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>alpha3.1</VersionSuffix>
11+
<VersionSuffix>alpha3.2</VersionSuffix>
1212
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1313
<FileVersion>$(VersionPrefix)</FileVersion>
1414
<Authors>The Synapse Authors</Authors>

src/core/Synapse.Core.Infrastructure/Services/Interfaces/IOAuth2TokenManager.cs renamed to src/runner/Synapse.Runner/Services/Interfaces/IOAuth2TokenManager.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
using ServerlessWorkflow.Sdk.Models.Authentication;
1515

16-
namespace Synapse.Core.Infrastructure.Services;
16+
namespace Synapse.Runner.Services;
1717

1818
/// <summary>
1919
/// Defines the fundamentals of a service used to manage <see cref="OAuth2Token"/>s

src/core/Synapse.Core.Infrastructure/Services/OAuth2TokenManager.cs renamed to src/runner/Synapse.Runner/Services/OAuth2TokenManager.cs

+2-4
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@
1212
// limitations under the License.
1313

1414
using IdentityModel.Client;
15-
using Microsoft.Extensions.Logging;
1615
using Microsoft.IdentityModel.JsonWebTokens;
1716
using Microsoft.IdentityModel.Tokens;
18-
using Neuroglia.Serialization;
19-
using ServerlessWorkflow.Sdk;
2017
using ServerlessWorkflow.Sdk.Models.Authentication;
2118
using System.Collections.Concurrent;
2219
using System.Net.Mime;
2320
using System.Security.Claims;
2421
using System.Text;
2522

26-
namespace Synapse.Core.Infrastructure.Services;
23+
namespace Synapse.Runner.Services;
2724

2825
/// <summary>
2926
/// Represents the default implementation of the <see cref="IOAuth2TokenManager"/> interface
@@ -69,6 +66,7 @@ public virtual async Task<OAuth2Token> GetTokenAsync(OAuth2AuthenticationSchemeD
6966
Address = configuration.Authority!.OriginalString,
7067
Policy = new()
7168
{
69+
ValidateIssuerName = false,
7270
RequireHttps = false
7371
}
7472
};

src/runner/Synapse.Runner/Synapse.Runner.csproj

+1-1
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>alpha3.1</VersionSuffix>
11+
<VersionSuffix>alpha3.2</VersionSuffix>
1212
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1313
<FileVersion>$(VersionPrefix)</FileVersion>
1414
<Authors>The Synapse Authors</Authors>

src/runtime/Synapse.Runtime.Abstractions/Synapse.Runtime.Abstractions.csproj

+1-1
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>alpha3.1</VersionSuffix>
10+
<VersionSuffix>alpha3.2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/runtime/Synapse.Runtime.Docker/Synapse.Runtime.Docker.csproj

+1-1
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>alpha3.1</VersionSuffix>
10+
<VersionSuffix>alpha3.2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/runtime/Synapse.Runtime.Kubernetes/Synapse.Runtime.Kubernetes.csproj

+1-1
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>alpha3.1</VersionSuffix>
10+
<VersionSuffix>alpha3.2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

src/runtime/Synapse.Runtime.Native/Synapse.Runtime.Native.csproj

+1-1
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>alpha3.1</VersionSuffix>
10+
<VersionSuffix>alpha3.2</VersionSuffix>
1111
<AssemblyVersion>$(VersionPrefix)</AssemblyVersion>
1212
<FileVersion>$(VersionPrefix)</FileVersion>
1313
<Authors>The Synapse Authors</Authors>

0 commit comments

Comments
 (0)