cleanup db migrations

This commit is contained in:
Paul Schneider 2026-03-01 20:14:54 +00:00
commit acc34aeee4
18 changed files with 13312 additions and 1081 deletions

View file

@ -0,0 +1,10 @@
public static class Constants
{
public static readonly string EXTERNAL_SCHEME = "oidc";
public static readonly string INTERNAL_SCHEME = "Cookies";
public static readonly string AUTHENTICATION_RESPONSE_TYPE = "code";
}

View file

@ -1,14 +1,21 @@
using System.Diagnostics;
using System.Net.Http.Headers;
using System.Runtime.CompilerServices;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Mvc;
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
using Yavsc.WebApiClient.Helpers;
namespace sampleWebAsWebApiClient.Controllers
{
public class HomeController(ILoggerFactory loggerFactory) : Controller
public class HomeController(ILoggerFactory loggerFactory,
OpenIdConnectOptions options
) : Controller
{
readonly ILogger _logger = loggerFactory.CreateLogger<HomeController>();
readonly OpenIdConnectOptions connectOptions = options;
[HttpGet]
public IActionResult Index()
@ -22,7 +29,7 @@ namespace sampleWebAsWebApiClient.Controllers
var client = new HttpClient();
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
var content = await client.GetStringAsync("https://localhost:6001/identity");
var content = await client.GetStringAsync(connectOptions.Authority);
ViewBag.Json = content;
return View("json");
@ -59,7 +66,7 @@ namespace sampleWebAsWebApiClient.Controllers
public IActionResult Logout()
{
return SignOut("Cookies", "Yavsc");
return SignOut(Constants.INTERNAL_SCHEME, Constants.EXTERNAL_SCHEME);
}
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]

View file

@ -17,20 +17,29 @@ JwtSecurityTokenHandler.DefaultMapInboundClaims = true;
var builder = WebApplication.CreateBuilder(args);
var authSection = builder.Configuration.GetSection("Authentication");
var issuer = authSection.GetValue<String>("Issuer");
var clientSection = authSection.GetSection("Client");
var clientId = clientSection.GetValue<String>("Id");
var clientSecret = clientSection.GetValue<String>("Secret");
builder.Services.AddControllersWithViews();
builder.Services
.AddAuthentication(options =>
{
options.DefaultScheme = "Cookies";
options.DefaultChallengeScheme = "oidc";
options.DefaultScheme = Constants.INTERNAL_SCHEME;
options.DefaultChallengeScheme = Constants.EXTERNAL_SCHEME;
})
.AddCookie("Cookies")
.AddOpenIdConnect("oidc", options =>
.AddCookie(Constants.INTERNAL_SCHEME)
.AddOpenIdConnect(Constants.EXTERNAL_SCHEME, options =>
{
options.Authority = builder.Configuration.GetValue<String>("AuthIssuer");
options.ClientId = "mvc";
options.ClientSecret = "49C1A7E1-0C79-4A89-A3D6-A37998FB86B0";
options.ResponseType = "code";
options.Authority = issuer;
options.ClientId = clientId;
options.ClientSecret = clientSecret;
options.ResponseType = Constants.AUTHENTICATION_RESPONSE_TYPE;
options.Scope.Add("openid");
options.Scope.Add("profile");
@ -43,7 +52,6 @@ builder.Services
using (var app = builder.Build())
{
if (app.Environment.IsDevelopment())
app.UseDeveloperExceptionPage();
else

View file

@ -1,4 +1,11 @@
{
"Authencication": {
"Issuer": "https://localhost:5001",
"Client": {
"Id": "mvc",
"Secret": "lame-secret"
}
},
"Logging": {
"LogLevel": {
"Default": "Information",
@ -6,7 +13,6 @@
}
},
"AllowedHosts": "*",
"AuthIssuer": "https://localhost:5001",
"Kestrel": {
"Endpoints":
{