From ada014eb5114c0cc96725ece3fd4c97222affc65 Mon Sep 17 00:00:00 2001 From: Berend Wouters Date: Tue, 11 Apr 2023 22:14:23 +0200 Subject: [PATCH] fix: disable the audience validation in dev --- .../Helpers/Extensions/AuthenticationExtensions.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Singer.API/Helpers/Extensions/AuthenticationExtensions.cs b/Singer.API/Helpers/Extensions/AuthenticationExtensions.cs index a89d255a..b1073480 100644 --- a/Singer.API/Helpers/Extensions/AuthenticationExtensions.cs +++ b/Singer.API/Helpers/Extensions/AuthenticationExtensions.cs @@ -3,6 +3,7 @@ using Microsoft.AspNetCore.Builder; using Microsoft.Extensions.Configuration; using Microsoft.Extensions.DependencyInjection; +using Microsoft.Extensions.Hosting; using Singer.Data.Models.Configuration; @@ -18,7 +19,14 @@ public static WebApplicationBuilder AddAuthenticationAndAuthorization(this WebAp .AddJwtBearer(options => { // The API resource scope issued in authorization server - options.TokenValidationParameters.ValidAudience = "singer.api"; + if(builder.Environment.IsDevelopment()) + { + options.TokenValidationParameters.ValidateAudience = false; + } + else + { + options.TokenValidationParameters.ValidAudience = "singer.api"; + } // URL of my authorization server options.Authority = applicationConfig.Authority; });