Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
ardalis committed Jul 28, 2020
1 parent f4bfc81 commit 2c9c7dd
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 28 deletions.
22 changes: 4 additions & 18 deletions src/PublicApi/Startup.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
using System;
using System.Collections.Generic;
using System.Text;
using AutoMapper;
using MediatR;

using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
Expand Down Expand Up @@ -46,11 +43,9 @@ public void ConfigureDevelopmentServices(IServiceCollection services)

private void ConfigureInMemoryDatabases(IServiceCollection services)
{
// use in-memory database
services.AddDbContext<CatalogContext>(c =>
c.UseInMemoryDatabase("Catalog"));

// Add Identity DbContext
services.AddDbContext<AppIdentityDbContext>(options =>
options.UseInMemoryDatabase("Identity"));

Expand Down Expand Up @@ -91,27 +86,18 @@ public void ConfigureServices(IServiceCollection services)
services.AddScoped(typeof(IAppLogger<>), typeof(LoggerAdapter<>));
services.AddScoped<ITokenClaimsService, IdentityTokenClaimService>();

// Add memory cache services
services.AddMemoryCache();

// https://stackoverflow.com/questions/46938248/asp-net-core-2-0-combining-cookies-and-bearer-authorization-for-the-same-endpoin
var key = Encoding.ASCII.GetBytes(AuthorizationConstants.JWT_SECRET_KEY);
services.AddAuthentication(config =>
{
//config.DefaultScheme = "smart";
//config.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
//config.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;

config.DefaultSignInScheme = JwtBearerDefaults.AuthenticationScheme;
config.DefaultAuthenticateScheme = JwtBearerDefaults.AuthenticationScheme;
config.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
config.DefaultScheme = JwtBearerDefaults.AuthenticationScheme;
})
.AddJwtBearer(x =>
.AddJwtBearer(config =>
{
x.RequireHttpsMetadata = false;
x.SaveToken = true;
x.TokenValidationParameters = new TokenValidationParameters
config.RequireHttpsMetadata = false;
config.SaveToken = true;
config.TokenValidationParameters = new TokenValidationParameters
{
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(key),
Expand Down
6 changes: 1 addition & 5 deletions src/Shared/Authorization/ClaimValue.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace Shared.Authorization
namespace Shared.Authorization
{
public class ClaimValue
{
Expand Down
5 changes: 1 addition & 4 deletions src/Shared/Authorization/UserInfo.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
using System;
using System.Collections.Generic;
using System.Security.Claims;
using System.Text;
using System.Collections.Generic;

namespace Shared.Authorization
{
Expand Down
2 changes: 1 addition & 1 deletion src/Web/Controllers/OrderController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public OrderController(IMediator mediator)
_mediator = mediator;
}

[HttpGet()]
[HttpGet]
public async Task<IActionResult> MyOrders()
{
var viewModel = await _mediator.Send(new GetMyOrders(User.Identity.Name));
Expand Down

0 comments on commit 2c9c7dd

Please sign in to comment.