diff --git a/deploy/k8s/archived/helm/basket-api/templates/configmap.yaml b/deploy/k8s/archived/helm/basket-api/templates/configmap.yaml index 2de0e28c7..8a36f74ac 100644 --- a/deploy/k8s/archived/helm/basket-api/templates/configmap.yaml +++ b/deploy/k8s/archived/helm/basket-api/templates/configmap.yaml @@ -12,7 +12,6 @@ metadata: data: basket__ConnectionString: {{ .Values.inf.redis.basket.constr }} urls__IdentityUrl: http://{{ .Values.app.svc.identity }} - basket__EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" all__EventBusConnection: {{ .Values.inf.eventbus.constr }} all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" \ No newline at end of file diff --git a/deploy/k8s/archived/helm/basket-api/values.yaml b/deploy/k8s/archived/helm/basket-api/values.yaml index 121de02de..dcd6aa763 100644 --- a/deploy/k8s/archived/helm/basket-api/values.yaml +++ b/deploy/k8s/archived/helm/basket-api/values.yaml @@ -36,8 +36,6 @@ env: key: all__UseAzureServiceBus - name: IdentityUrl key: urls__IdentityUrl - - name: UseLoadTest - key: basket__EnableLoadTest # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) values: - name: OrchestratorType diff --git a/deploy/k8s/archived/helm/inf.yaml b/deploy/k8s/archived/helm/inf.yaml index e73b37ee8..1ce48d67e 100644 --- a/deploy/k8s/archived/helm/inf.yaml +++ b/deploy/k8s/archived/helm/inf.yaml @@ -38,7 +38,6 @@ inf: dns: "" # k8s external DNS. This value or ip value MUST BE PROVIDED local: false # True when deploying on "local K8s" provided by Docker Desktop. misc: # inf.misc contains miscellaneous configuration related to infrastructure - useLoadTest: false # If running under loading test or not useAzureStorage: false # If catalog api uses azure storage or not # registry: # Uncomment "registry" to specify registry secret # secretName: # secretName is the name of the secret inside k8s diff --git a/deploy/k8s/archived/helm/mobileshoppingagg/templates/configmap.yaml b/deploy/k8s/archived/helm/mobileshoppingagg/templates/configmap.yaml index 6d3eeef4b..b55afbdb2 100644 --- a/deploy/k8s/archived/helm/mobileshoppingagg/templates/configmap.yaml +++ b/deploy/k8s/archived/helm/mobileshoppingagg/templates/configmap.yaml @@ -11,7 +11,6 @@ metadata: heritage: {{ .Release.Service }} data: all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" - all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" mobileshoppingagg__keystore: {{ .Values.inf.redis.keystore.constr }} internalurls__basket: http://{{ .Values.app.svc.basket }} internalurls__catalog: http://{{ .Values.app.svc.catalog }} diff --git a/deploy/k8s/archived/helm/ordering-api/templates/configmap.yaml b/deploy/k8s/archived/helm/ordering-api/templates/configmap.yaml index e64a6c841..e93dddd5c 100644 --- a/deploy/k8s/archived/helm/ordering-api/templates/configmap.yaml +++ b/deploy/k8s/archived/helm/ordering-api/templates/configmap.yaml @@ -12,7 +12,6 @@ metadata: heritage: {{ .Release.Service }} data: ordering__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.ordering.db }};User Id={{ .Values.inf.sql.common.user }};Password={{ .Values.inf.sql.common.pwd }}; - ordering__EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" urls__IdentityUrl: http://{{ .Values.app.svc.identity }} all__EventBusConnection: {{ .Values.inf.eventbus.constr }} all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" diff --git a/deploy/k8s/archived/helm/ordering-api/values.yaml b/deploy/k8s/archived/helm/ordering-api/values.yaml index 7eff1a48b..505ccc379 100644 --- a/deploy/k8s/archived/helm/ordering-api/values.yaml +++ b/deploy/k8s/archived/helm/ordering-api/values.yaml @@ -41,8 +41,6 @@ env: key: all__EventBusConnection - name: AzureServiceBusEnabled key: all__UseAzureServiceBus - - name: UseLoadTest - key: ordering__EnableLoadTest - name: IdentityUrl key: urls__IdentityUrl # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) diff --git a/deploy/k8s/archived/helm/ordering-backgroundtasks/templates/configmap.yaml b/deploy/k8s/archived/helm/ordering-backgroundtasks/templates/configmap.yaml index 7ed4a0e8e..928692c57 100644 --- a/deploy/k8s/archived/helm/ordering-backgroundtasks/templates/configmap.yaml +++ b/deploy/k8s/archived/helm/ordering-backgroundtasks/templates/configmap.yaml @@ -13,7 +13,6 @@ metadata: heritage: {{ .Release.Service }} data: ordering__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.ordering.db }};User Id={{ .Values.inf.sql.common.user }};Password={{ .Values.inf.sql.common.pwd }}; - ordering__EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" all__EventBusConnection: {{ .Values.inf.eventbus.constr }} all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" diff --git a/deploy/k8s/archived/helm/ordering-backgroundtasks/values.yaml b/deploy/k8s/archived/helm/ordering-backgroundtasks/values.yaml index d065f0345..18abe99a5 100644 --- a/deploy/k8s/archived/helm/ordering-backgroundtasks/values.yaml +++ b/deploy/k8s/archived/helm/ordering-backgroundtasks/values.yaml @@ -44,8 +44,6 @@ env: key: all__EventBusConnection - name: AzureServiceBusEnabled key: all__UseAzureServiceBus - - name: UseLoadTest - key: ordering__EnableLoadTest - name: CheckUpdateTime key: graceperiodmanager__CheckUpdateTime - name: GracePeriodTime diff --git a/deploy/k8s/archived/helm/webmvc/templates/configmap.yaml b/deploy/k8s/archived/helm/webmvc/templates/configmap.yaml index 89b9faae0..2062bdabc 100644 --- a/deploy/k8s/archived/helm/webmvc/templates/configmap.yaml +++ b/deploy/k8s/archived/helm/webmvc/templates/configmap.yaml @@ -16,7 +16,6 @@ metadata: data: all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" - all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" webmvc__keystore: {{ .Values.inf.redis.keystore.constr }} internalurls__apigwws: http://{{ .Values.app.svc.webshoppingapigw }} internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc diff --git a/deploy/k8s/archived/helm/webmvc/values.yaml b/deploy/k8s/archived/helm/webmvc/values.yaml index 5db29dd01..1f40dbb03 100644 --- a/deploy/k8s/archived/helm/webmvc/values.yaml +++ b/deploy/k8s/archived/helm/webmvc/values.yaml @@ -32,8 +32,6 @@ env: configmap: - name: ApplicationInsights__InstrumentationKey key: all__InstrumentationKey - - name: UseLoadTest - key: all_EnableLoadTest - name: DPConnectionString key: webmvc__keystore - name: PurchaseUrl diff --git a/deploy/k8s/archived/helm/webshoppingagg/templates/configmap.yaml b/deploy/k8s/archived/helm/webshoppingagg/templates/configmap.yaml index b1b07ffee..b21de5a38 100644 --- a/deploy/k8s/archived/helm/webshoppingagg/templates/configmap.yaml +++ b/deploy/k8s/archived/helm/webshoppingagg/templates/configmap.yaml @@ -11,7 +11,6 @@ metadata: heritage: {{ .Release.Service }} data: all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" - all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" webshoppingagg__keystore: {{ .Values.inf.redis.keystore.constr }} internalurls__basket: http://{{ .Values.app.svc.basket }} internalurls__catalog: http://{{ .Values.app.svc.catalog }} diff --git a/deploy/k8s/archived/helm/webspa/values.yaml b/deploy/k8s/archived/helm/webspa/values.yaml index 4a7eea52b..08e148111 100644 --- a/deploy/k8s/archived/helm/webspa/values.yaml +++ b/deploy/k8s/archived/helm/webspa/values.yaml @@ -32,8 +32,6 @@ env: configmap: - name: ApplicationInsights__InstrumentationKey key: all__InstrumentationKey - - name: UseLoadTest - key: all_EnableLoadTest - name: DPConnectionString key: webspa__keystore - name: PurchaseUrl diff --git a/deploy/k8s/helm/basket-api/templates/configmap.yaml b/deploy/k8s/helm/basket-api/templates/configmap.yaml index 2de0e28c7..8a36f74ac 100644 --- a/deploy/k8s/helm/basket-api/templates/configmap.yaml +++ b/deploy/k8s/helm/basket-api/templates/configmap.yaml @@ -12,7 +12,6 @@ metadata: data: basket__ConnectionString: {{ .Values.inf.redis.basket.constr }} urls__IdentityUrl: http://{{ .Values.app.svc.identity }} - basket__EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" all__EventBusConnection: {{ .Values.inf.eventbus.constr }} all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" \ No newline at end of file diff --git a/deploy/k8s/helm/basket-api/values.yaml b/deploy/k8s/helm/basket-api/values.yaml index 121de02de..dcd6aa763 100644 --- a/deploy/k8s/helm/basket-api/values.yaml +++ b/deploy/k8s/helm/basket-api/values.yaml @@ -36,8 +36,6 @@ env: key: all__UseAzureServiceBus - name: IdentityUrl key: urls__IdentityUrl - - name: UseLoadTest - key: basket__EnableLoadTest # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) values: - name: OrchestratorType diff --git a/deploy/k8s/helm/inf.yaml b/deploy/k8s/helm/inf.yaml index e73b37ee8..1ce48d67e 100644 --- a/deploy/k8s/helm/inf.yaml +++ b/deploy/k8s/helm/inf.yaml @@ -38,7 +38,6 @@ inf: dns: "" # k8s external DNS. This value or ip value MUST BE PROVIDED local: false # True when deploying on "local K8s" provided by Docker Desktop. misc: # inf.misc contains miscellaneous configuration related to infrastructure - useLoadTest: false # If running under loading test or not useAzureStorage: false # If catalog api uses azure storage or not # registry: # Uncomment "registry" to specify registry secret # secretName: # secretName is the name of the secret inside k8s diff --git a/deploy/k8s/helm/mobileshoppingagg/templates/configmap.yaml b/deploy/k8s/helm/mobileshoppingagg/templates/configmap.yaml index 6d3eeef4b..b55afbdb2 100644 --- a/deploy/k8s/helm/mobileshoppingagg/templates/configmap.yaml +++ b/deploy/k8s/helm/mobileshoppingagg/templates/configmap.yaml @@ -11,7 +11,6 @@ metadata: heritage: {{ .Release.Service }} data: all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" - all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" mobileshoppingagg__keystore: {{ .Values.inf.redis.keystore.constr }} internalurls__basket: http://{{ .Values.app.svc.basket }} internalurls__catalog: http://{{ .Values.app.svc.catalog }} diff --git a/deploy/k8s/helm/ordering-api/templates/configmap.yaml b/deploy/k8s/helm/ordering-api/templates/configmap.yaml index e64a6c841..e93dddd5c 100644 --- a/deploy/k8s/helm/ordering-api/templates/configmap.yaml +++ b/deploy/k8s/helm/ordering-api/templates/configmap.yaml @@ -12,7 +12,6 @@ metadata: heritage: {{ .Release.Service }} data: ordering__ConnectionString: Server={{ $sqlsrv }};Initial Catalog={{ .Values.inf.sql.ordering.db }};User Id={{ .Values.inf.sql.common.user }};Password={{ .Values.inf.sql.common.pwd }}; - ordering__EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" urls__IdentityUrl: http://{{ .Values.app.svc.identity }} all__EventBusConnection: {{ .Values.inf.eventbus.constr }} all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" diff --git a/deploy/k8s/helm/ordering-api/values.yaml b/deploy/k8s/helm/ordering-api/values.yaml index 7eff1a48b..505ccc379 100644 --- a/deploy/k8s/helm/ordering-api/values.yaml +++ b/deploy/k8s/helm/ordering-api/values.yaml @@ -41,8 +41,6 @@ env: key: all__EventBusConnection - name: AzureServiceBusEnabled key: all__UseAzureServiceBus - - name: UseLoadTest - key: ordering__EnableLoadTest - name: IdentityUrl key: urls__IdentityUrl # values define environment variables with a fixed value (no configmap involved) (name is name of var, and value is its value) diff --git a/deploy/k8s/helm/ordering-backgroundtasks/values.yaml b/deploy/k8s/helm/ordering-backgroundtasks/values.yaml index d065f0345..18abe99a5 100644 --- a/deploy/k8s/helm/ordering-backgroundtasks/values.yaml +++ b/deploy/k8s/helm/ordering-backgroundtasks/values.yaml @@ -44,8 +44,6 @@ env: key: all__EventBusConnection - name: AzureServiceBusEnabled key: all__UseAzureServiceBus - - name: UseLoadTest - key: ordering__EnableLoadTest - name: CheckUpdateTime key: graceperiodmanager__CheckUpdateTime - name: GracePeriodTime diff --git a/deploy/k8s/helm/webmvc/templates/configmap.yaml b/deploy/k8s/helm/webmvc/templates/configmap.yaml index 89b9faae0..2062bdabc 100644 --- a/deploy/k8s/helm/webmvc/templates/configmap.yaml +++ b/deploy/k8s/helm/webmvc/templates/configmap.yaml @@ -16,7 +16,6 @@ metadata: data: all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" - all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" webmvc__keystore: {{ .Values.inf.redis.keystore.constr }} internalurls__apigwws: http://{{ .Values.app.svc.webshoppingapigw }} internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc diff --git a/deploy/k8s/helm/webmvc/values.yaml b/deploy/k8s/helm/webmvc/values.yaml index 5db29dd01..1f40dbb03 100644 --- a/deploy/k8s/helm/webmvc/values.yaml +++ b/deploy/k8s/helm/webmvc/values.yaml @@ -32,8 +32,6 @@ env: configmap: - name: ApplicationInsights__InstrumentationKey key: all__InstrumentationKey - - name: UseLoadTest - key: all_EnableLoadTest - name: DPConnectionString key: webmvc__keystore - name: PurchaseUrl diff --git a/deploy/k8s/helm/webshoppingagg/templates/configmap.yaml b/deploy/k8s/helm/webshoppingagg/templates/configmap.yaml index b1b07ffee..b21de5a38 100644 --- a/deploy/k8s/helm/webshoppingagg/templates/configmap.yaml +++ b/deploy/k8s/helm/webshoppingagg/templates/configmap.yaml @@ -11,7 +11,6 @@ metadata: heritage: {{ .Release.Service }} data: all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" - all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" webshoppingagg__keystore: {{ .Values.inf.redis.keystore.constr }} internalurls__basket: http://{{ .Values.app.svc.basket }} internalurls__catalog: http://{{ .Values.app.svc.catalog }} diff --git a/deploy/k8s/helm/webspa/templates/configmap.yaml b/deploy/k8s/helm/webspa/templates/configmap.yaml index 353ff638f..e5ca69308 100644 --- a/deploy/k8s/helm/webspa/templates/configmap.yaml +++ b/deploy/k8s/helm/webspa/templates/configmap.yaml @@ -16,7 +16,6 @@ metadata: heritage: {{ .Release.Service }} data: all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" - all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" webspa__keystore: {{ .Values.inf.redis.keystore.constr }} internalurls__apigwws: http://{{ .Values.app.svc.webshoppingapigw }} internalurls__identity__hc: http://{{ .Values.app.svc.identity }}/hc diff --git a/deploy/k8s/helm/webspa/values.yaml b/deploy/k8s/helm/webspa/values.yaml index 4a7eea52b..08e148111 100644 --- a/deploy/k8s/helm/webspa/values.yaml +++ b/deploy/k8s/helm/webspa/values.yaml @@ -32,8 +32,6 @@ env: configmap: - name: ApplicationInsights__InstrumentationKey key: all__InstrumentationKey - - name: UseLoadTest - key: all_EnableLoadTest - name: DPConnectionString key: webspa__keystore - name: PurchaseUrl diff --git a/deploy/k8s/helm/webstatus/templates/configmap.yaml b/deploy/k8s/helm/webstatus/templates/configmap.yaml index b53864602..60bd41489 100644 --- a/deploy/k8s/helm/webstatus/templates/configmap.yaml +++ b/deploy/k8s/helm/webstatus/templates/configmap.yaml @@ -16,7 +16,6 @@ metadata: data: all__InstrumentationKey: "{{ .Values.inf.appinsights.key }}" all__UseAzureServiceBus: "{{ .Values.inf.eventbus.useAzure }}" - all_EnableLoadTest: "{{ .Values.inf.misc.useLoadTest }}" webstatus__keystore: {{ .Values.inf.redis.keystore.constr }} name__mvc__hc: WebMVC HTTP Check internalurls__mvc__hc: http://{{ .Values.app.svc.mvc }}/hc diff --git a/src/.env b/src/.env index d65bdbbf6..3aac89a3f 100644 --- a/src/.env +++ b/src/.env @@ -32,5 +32,4 @@ ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP=10.121.122.162 #ESHOP_AZURE_STORAGE_CATALOG_KEY= #ESHOP_SERVICE_BUS_USERNAME= #ESHOP_SERVICE_BUS_PASSWORD= -#INSTRUMENTATION_KEY= -#USE_LOADTEST= \ No newline at end of file +#INSTRUMENTATION_KEY= \ No newline at end of file diff --git a/src/Services/Basket/Basket.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs b/src/Services/Basket/Basket.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs deleted file mode 100644 index 2f5eb28b6..000000000 --- a/src/Services/Basket/Basket.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs +++ /dev/null @@ -1,79 +0,0 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Primitives; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Claims; -using System.Threading.Tasks; - -namespace Basket.API.Infrastructure.Middlewares -{ - class ByPassAuthMiddleware - { - private readonly RequestDelegate _next; - private string _currentUserId; - public ByPassAuthMiddleware(RequestDelegate next) - { - _next = next; - _currentUserId = null; - } - - - public async Task Invoke(HttpContext context) - { - var path = context.Request.Path; - if (path == "/noauth") - { - var userid = context.Request.Query["userid"]; - if (!string.IsNullOrEmpty(userid)) - { - _currentUserId = userid; - } - context.Response.StatusCode = 200; - context.Response.ContentType = "text/string"; - await context.Response.WriteAsync($"User set to {_currentUserId}"); - } - - else if (path == "/noauth/reset") - { - _currentUserId = null; - context.Response.StatusCode = 200; - context.Response.ContentType = "text/string"; - await context.Response.WriteAsync($"User set to none. Token required for protected endpoints."); - } - else - { - var currentUserId = _currentUserId; - - var authHeader = context.Request.Headers["Authorization"]; - if (authHeader != StringValues.Empty) - { - var header = authHeader.FirstOrDefault(); - if (!string.IsNullOrEmpty(header) && header.StartsWith("Email ") && header.Length > "Email ".Length) - { - currentUserId = header.Substring("Email ".Length); - } - } - - - if (!string.IsNullOrEmpty(currentUserId)) - { - var user = new ClaimsIdentity(new[] { - new Claim("emails", currentUserId), - new Claim("name", "Test user"), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", "Test user"), - new Claim("nonce", Guid.NewGuid().ToString()), - new Claim("http://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","User"), - new Claim("sub", currentUserId), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname","Microsoft")} - , "ByPassAuth"); - - context.User = new ClaimsPrincipal(user); - } - - await _next.Invoke(context); - } - } - } -} diff --git a/src/Services/Basket/Basket.API/Startup.cs b/src/Services/Basket/Basket.API/Startup.cs index e8576b238..7b4d6b96b 100644 --- a/src/Services/Basket/Basket.API/Startup.cs +++ b/src/Services/Basket/Basket.API/Startup.cs @@ -275,11 +275,6 @@ namespace Microsoft.eShopOnContainers.Services.Basket.API protected virtual void ConfigureAuth(IApplicationBuilder app) { - if (Configuration.GetValue("UseLoadTest")) - { - app.UseMiddleware(); - } - app.UseAuthentication(); app.UseAuthorization(); } diff --git a/src/Services/Ordering/Ordering.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs b/src/Services/Ordering/Ordering.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs deleted file mode 100644 index a76b79a21..000000000 --- a/src/Services/Ordering/Ordering.API/Infrastructure/Middlewares/ByPassAuthMiddleware.cs +++ /dev/null @@ -1,79 +0,0 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Primitives; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Claims; -using System.Threading.Tasks; - -namespace Ordering.API.Infrastructure.Middlewares -{ - class ByPassAuthMiddleware - { - private readonly RequestDelegate _next; - private string _currentUserId; - public ByPassAuthMiddleware(RequestDelegate next) - { - _next = next; - _currentUserId = null; - } - - - public async Task Invoke(HttpContext context) - { - var path = context.Request.Path; - if (path == "/noauth") - { - var userid = context.Request.Query["userid"]; - if (!string.IsNullOrEmpty(userid)) - { - _currentUserId = userid; - } - context.Response.StatusCode = 200; - context.Response.ContentType = "text/string"; - await context.Response.WriteAsync($"User set to {_currentUserId}"); - } - - else if (path == "/noauth/reset") - { - _currentUserId = null; - context.Response.StatusCode = 200; - context.Response.ContentType = "text/string"; - await context.Response.WriteAsync($"User set to none. Token required for protected endpoints."); - } - else - { - var currentUserId = _currentUserId; - - var authHeader = context.Request.Headers["Authorization"]; - if (authHeader != StringValues.Empty) - { - var header = authHeader.FirstOrDefault(); - if (!string.IsNullOrEmpty(header) && header.StartsWith("Email ") && header.Length > "Email ".Length) - { - currentUserId = header.Substring("Email ".Length); - } - } - - - if (!string.IsNullOrEmpty(currentUserId)) - { - var user = new ClaimsIdentity(new[] { - new Claim("emails", currentUserId), - new Claim("name", "Test user"), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", "Test user"), - new Claim("nonce", Guid.NewGuid().ToString()), - new Claim("http://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"), - new Claim("sub", currentUserId), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","User"), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname","Microsoft")} - , "ByPassAuth"); - - context.User = new ClaimsPrincipal(user); - } - - await _next.Invoke(context); - } - } - } -} diff --git a/src/Services/Ordering/Ordering.API/Startup.cs b/src/Services/Ordering/Ordering.API/Startup.cs index f0e251b89..445d0b873 100644 --- a/src/Services/Ordering/Ordering.API/Startup.cs +++ b/src/Services/Ordering/Ordering.API/Startup.cs @@ -6,7 +6,6 @@ using global::Ordering.API.Application.IntegrationEvents; using global::Ordering.API.Application.IntegrationEvents.Events; using global::Ordering.API.Infrastructure.Filters; - using global::Ordering.API.Infrastructure.Middlewares; using GrpcOrdering; using HealthChecks.UI.Client; using Infrastructure.AutofacModules; @@ -149,11 +148,6 @@ protected virtual void ConfigureAuth(IApplicationBuilder app) { - if (Configuration.GetValue("UseLoadTest")) - { - app.UseMiddleware(); - } - app.UseAuthentication(); app.UseAuthorization(); } diff --git a/src/Services/Webhooks/Webhooks.API/Startup.cs b/src/Services/Webhooks/Webhooks.API/Startup.cs index c8073e1a0..e23d927a8 100644 --- a/src/Services/Webhooks/Webhooks.API/Startup.cs +++ b/src/Services/Webhooks/Webhooks.API/Startup.cs @@ -112,13 +112,6 @@ namespace Webhooks.API protected virtual void ConfigureAuth(IApplicationBuilder app) { - /* - if (Configuration.GetValue("UseLoadTest")) - { - app.UseMiddleware(); - } - */ - app.UseAuthentication(); app.UseAuthorization(); } diff --git a/src/Web/WebMVC/Infrastructure/Middlewares/ByPassAuthMiddleware.cs b/src/Web/WebMVC/Infrastructure/Middlewares/ByPassAuthMiddleware.cs deleted file mode 100644 index 4661aa13c..000000000 --- a/src/Web/WebMVC/Infrastructure/Middlewares/ByPassAuthMiddleware.cs +++ /dev/null @@ -1,80 +0,0 @@ -using Microsoft.AspNetCore.Http; -using Microsoft.Extensions.Primitives; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Security.Claims; -using System.Threading.Tasks; - -namespace WebMVC.Infrastructure.Middlewares -{ - class ByPassAuthMiddleware - { - private readonly RequestDelegate _next; - private string _currentUserId; - public ByPassAuthMiddleware(RequestDelegate next) - { - _next = next; - _currentUserId = null; - } - - - public async Task Invoke(HttpContext context) - { - var path = context.Request.Path; - if (path == "/noauth") - { - var userid = context.Request.Query["userid"]; - if (!string.IsNullOrEmpty(userid)) - { - _currentUserId = userid; - } - context.Response.StatusCode = 200; - context.Response.ContentType = "text/string"; - await context.Response.WriteAsync($"User set to {_currentUserId}"); - } - - else if (path == "/noauth/reset") - { - _currentUserId = null; - context.Response.StatusCode = 200; - context.Response.ContentType = "text/string"; - await context.Response.WriteAsync($"User set to none. Token required for protected endpoints."); - } - else - { - var currentUserId = _currentUserId; - - var authHeader = context.Request.Headers["Authorization"]; - if (authHeader != StringValues.Empty) - { - var header = authHeader.FirstOrDefault(); - if (!string.IsNullOrEmpty(header) && header.StartsWith("Email ") && header.Length > "Email ".Length) - { - currentUserId = header.Substring("Email ".Length); - } - } - - - if (!string.IsNullOrEmpty(currentUserId)) - { - var user = new ClaimsIdentity(new[] { - new Claim("emails", currentUserId), - new Claim("name", "Test user"), - new Claim("nonce", Guid.NewGuid().ToString()), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/name", "Test user"), - new Claim("http://schemas.microsoft.com/identity/claims/identityprovider", "ByPassAuthMiddleware"), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname","User"), - new Claim("sub", currentUserId), - new Claim("card_expiration", "12/21"), - new Claim("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname","Microsoft")} - , "ByPassAuth"); - - context.User = new ClaimsPrincipal(user); - } - - await _next.Invoke(context); - } - } - } -} diff --git a/src/Web/WebMVC/Startup.cs b/src/Web/WebMVC/Startup.cs index f4570c71e..65b3957c6 100644 --- a/src/Web/WebMVC/Startup.cs +++ b/src/Web/WebMVC/Startup.cs @@ -21,7 +21,6 @@ using System; using System.IdentityModel.Tokens.Jwt; using System.Net.Http; using WebMVC.Infrastructure; -using WebMVC.Infrastructure.Middlewares; using WebMVC.Services; namespace Microsoft.eShopOnContainers.WebMVC @@ -76,11 +75,6 @@ namespace Microsoft.eShopOnContainers.WebMVC app.UseStaticFiles(); app.UseSession(); - if (Configuration.GetValue("UseLoadTest")) - { - app.UseMiddleware(); - } - WebContextSeed.Seed(app, env); // Fix samesite issue when running eShop from docker-compose locally as by default http protocol is being used @@ -185,7 +179,6 @@ namespace Microsoft.eShopOnContainers.WebMVC public static IServiceCollection AddCustomAuthentication(this IServiceCollection services, IConfiguration configuration) { - var useLoadTest = configuration.GetValue("UseLoadTest"); var identityUrl = configuration.GetValue("IdentityUrl"); var callBackUrl = configuration.GetValue("CallBackUrl"); var sessionCookieLifetime = configuration.GetValue("SessionCookieLifetimeMinutes", 60); @@ -203,9 +196,9 @@ namespace Microsoft.eShopOnContainers.WebMVC options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme; options.Authority = identityUrl.ToString(); options.SignedOutRedirectUri = callBackUrl.ToString(); - options.ClientId = useLoadTest ? "mvctest" : "mvc"; + options.ClientId = "mvc"; options.ClientSecret = "secret"; - options.ResponseType = useLoadTest ? "code id_token token" : "code id_token"; + options.ResponseType = "code id_token"; options.SaveTokens = true; options.GetClaimsFromUserInfoEndpoint = true; options.RequireHttpsMetadata = false;