Skip to content

Commit 4cee70c

Browse files
Merge pull request #41 from StuartFerguson/bug/#40_tokenvalidationissue
Bug fix for token validation completed
2 parents 5650162 + f2aa1a3 commit 4cee70c

File tree

8 files changed

+70
-221
lines changed

8 files changed

+70
-221
lines changed

MessagingService.IntegrationTests/Email/SendEmail.feature

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
Feature: SendEmail
33

44
Background:
5+
6+
Given I create the following api scopes
7+
| Name | DisplayName | Description |
8+
| messagingService | Messaging REST Scope | A scope for Messaging REST |
9+
510
Given the following api resources exist
611
| ResourceName | DisplayName | Secret | Scopes | UserClaims |
712
| messagingService | Messaging REST | Secret1 | messagingService | |

MessagingService.IntegrationTests/Email/SendEmail.feature.cs

Lines changed: 28 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MessagingService.IntegrationTests/MessagingService.IntegrationTests.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<PackageReference Include="ClientProxyBase" Version="1.0.3" />
1111
<PackageReference Include="Ductus.FluentDocker" Version="2.7.3" />
1212
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.8.3" />
13-
<PackageReference Include="SecurityService.Client" Version="1.0.4" />
13+
<PackageReference Include="SecurityService.Client" Version="1.0.4.1" />
1414
<PackageReference Include="Shared.IntegrationTesting" Version="1.0.3" />
1515
<PackageReference Include="Shouldly" Version="4.0.3" />
1616
<PackageReference Include="SpecFlow.Tools.MsBuild.Generation" Version="3.5.14" />

MessagingService.IntegrationTests/SMS/SendSMS.feature

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
Feature: SendSMS
33

44
Background:
5+
6+
Given I create the following api scopes
7+
| Name | DisplayName | Description |
8+
| messagingService | Messaging REST Scope | A scope for Messaging REST |
9+
510
Given the following api resources exist
611
| ResourceName | DisplayName | Secret | Scopes | UserClaims |
712
| messagingService | Messaging REST | Secret1 | messagingService | |

MessagingService.IntegrationTests/SMS/SendSMS.feature.cs

Lines changed: 3 additions & 201 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

MessagingService.IntegrationTests/Shared/SharedSteps.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,32 @@ public SharedSteps(ScenarioContext scenarioContext,
3030
this.TestingContext = testingContext;
3131
}
3232

33+
[Given(@"I create the following api scopes")]
34+
public async Task GivenICreateTheFollowingApiScopes(Table table)
35+
{
36+
foreach (TableRow tableRow in table.Rows)
37+
{
38+
CreateApiScopeRequest createApiScopeRequest = new CreateApiScopeRequest
39+
{
40+
Name = SpecflowTableHelper.GetStringRowValue(tableRow, "Name"),
41+
Description = SpecflowTableHelper.GetStringRowValue(tableRow, "Description"),
42+
DisplayName = SpecflowTableHelper.GetStringRowValue(tableRow, "DisplayName")
43+
};
44+
var createApiScopeResponse =
45+
await this.CreateApiScope(createApiScopeRequest, CancellationToken.None).ConfigureAwait(false);
46+
47+
createApiScopeResponse.ShouldNotBeNull();
48+
createApiScopeResponse.ApiScopeName.ShouldNotBeNullOrEmpty();
49+
}
50+
}
51+
52+
private async Task<CreateApiScopeResponse> CreateApiScope(CreateApiScopeRequest createApiScopeRequest,
53+
CancellationToken cancellationToken)
54+
{
55+
CreateApiScopeResponse createApiScopeResponse = await this.TestingContext.DockerHelper.SecurityServiceClient.CreateApiScope(createApiScopeRequest, cancellationToken).ConfigureAwait(false);
56+
return createApiScopeResponse;
57+
}
58+
3359
[Given(@"the following api resources exist")]
3460
public async Task GivenTheFollowingApiResourcesExist(Table table)
3561
{

MessagingService/MessagingService.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,11 @@
88
<ItemGroup>
99
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="5.0.1" />
1010
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="5.0.1" />
11+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="5.0.2" />
1112
<PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="5.0.2" />
1213
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.10.8" />
1314
<PackageReference Include="Shared" Version="1.0.3" />
1415
<PackageReference Include="Shared.EventStore" Version="1.0.3" />
15-
<PackageReference Include="IdentityServer4.AccessTokenValidation" Version="3.0.1" />
1616
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="4.2.0" />
1717
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="4.2.0" />
1818
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="5.0.0" />

MessagingService/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ private void ConfigureMiddlewareServices(IServiceCollection services)
269269
options.TokenValidationParameters = new Microsoft.IdentityModel.Tokens.TokenValidationParameters()
270270
{
271271
ValidateIssuer = true,
272-
ValidateAudience = true,
272+
ValidateAudience = false,
273273
ValidAudience = ConfigurationReader.GetValue("SecurityConfiguration", "ApiName"),
274274
ValidIssuer = ConfigurationReader.GetValue("SecurityConfiguration", "Authority"),
275275
};

0 commit comments

Comments
 (0)