Web API client connected

This commit is contained in:
Paul Schneider 2024-11-12 08:32:15 +00:00
commit 716bfb2e05
23 changed files with 225 additions and 339 deletions

View file

@ -13,7 +13,6 @@ namespace Yavsc.Controllers
{
[Produces("application/json")]
[Route("api/blog")]
[AllowAnonymous]
public class BlogApiController : Controller
{

View file

@ -14,7 +14,7 @@ using Yavsc.Models.Billing;
namespace Yavsc.Controllers
{
[Produces("application/json")]
[Route("api/estimate"), Authorize()]
[Route("api/estimate"), Authorize]
public class EstimateApiController : Controller
{
private readonly ApplicationDbContext _context;

View file

@ -135,6 +135,8 @@ internal static class HostingExtensions
public static WebApplication ConfigureServices(this WebApplicationBuilder builder)
{
var siteSection = builder.Configuration.GetSection("Site");
var smtpSection = builder.Configuration.GetSection("Smtp");
var paypalSection = builder.Configuration.GetSection("Authentication:PayPal");
@ -156,7 +158,10 @@ internal static class HostingExtensions
string? googleClientId = builder.Configuration["Authentication:Google:ClientId"];
string? googleClientSecret = builder.Configuration["Authentication:Google:ClientSecret"];
var services = builder.Services;
_ = services.AddControllersWithViews()
.AddNewtonsoftJson();
LoadGoogleConfig(builder.Configuration);
services.Configure<SiteSettings>(siteSection);
services.Configure<SmtpSettings>(smtpSection);
services.Configure<PayPalSettings>(paypalSection);
@ -189,8 +194,11 @@ internal static class HostingExtensions
.AddInMemoryIdentityResources(Config.IdentityResources)
.AddInMemoryApiScopes(Config.ApiScopes)
.AddInMemoryClients(Config.Clients)
.AddDeveloperSigningCredential()
;
services.AddSession();
// TODO .AddServerSideSessionStore<YavscServerSideSessionStore>()
@ -315,9 +323,6 @@ internal static class HostingExtensions
services.AddSingleton<IAuthorizationHandler, PermissionHandler>();
_ = services.AddControllersWithViews()
.AddNewtonsoftJson();
LoadGoogleConfig(builder.Configuration);
return builder.Build();
}
@ -328,11 +333,14 @@ internal static class HostingExtensions
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
}
app.UseStaticFiles();
app.UseRouting();
app.UseIdentityServer();
//app.UseSignalR();
app.UseAuthorization();
app.MapControllerRoute(
name: "default",

View file

@ -9,6 +9,7 @@ namespace Yavsc
public static void Main(string[] args)
{
var builder = WebApplication.CreateBuilder(args);
builder.Configuration
.AddJsonFile("appsettings.json")
.AddJsonFile($"appsettings.{builder.Environment.EnvironmentName}.json", optional: true)

View file

@ -103,3 +103,21 @@ Hello !!!
</asciidoc>
<ul>
<li>
IdentityServer publishes a
<a href="~/.well-known/openid-configuration">discovery document</a>
where you can find metadata and links to all the endpoints, key material, etc.
</li>
<li>
Click <a href="~/diagnostics">here</a> to see the claims for your current session.
</li>
<li>
Click <a href="~/grants">here</a> to manage your stored grants.
</li>
<li>
Here are links to the
<a href="https://github.com/identityserver/IdentityServer4">source code repository</a>,
and <a href="https://github.com/IdentityServer/IdentityServer4/tree/main/samples">ready to use samples</a>.
</li>
</ul>

1
src/Yavsc/tempkey.jwk Normal file
View file

@ -0,0 +1 @@
{"AdditionalData":{},"Alg":"RS256","Crv":null,"D":"BBXYWCFMOYOt4QTTDtjmvrbhj20p07lIjqZv6kdsEUdkrsc0p2stHYp6yT8SLxPAqMgSiFmr29jHdS56gVUa9FEe1H7DXDZszgZ8JRGWaIa2fe2_2vD-hPzFxJNmS5zlo7mFaH0lL40imi7qyzDt3lmvZnBEhwNpGeg2Ge5rmDsT9w5zeDAfLnOOC4ghUNFfQnmVZQfjsXPt46MDkj94ZInOwqJBxbjhNJSvJWkW9y3PG02bPriBx6bsHdc7yPilsqICnnLRWxb79n6XJHZ-gHO1l-eeXwAj5gJI-CX_V7INjBAuNFTMJrCbf-hpghVadsIKLLK6QOeRbdA_6JzGQQ","DP":"EaH8Zw1B6y4cJTb9EzzzPLW20YXihxB8a1ywnYOekqlRS0vUJI8hh9IayWu56PKnIwVYnWlyIn-YreBTBpRubuyc26cyEYsnqGi44K0nnN3n43LBl5BpenI_AE9gLNmP2TAngPD0vINpg9fqTXNutEsNBF_6BLkqzC52rGLMGNk","DQ":"BWlE0UknVFCZ99HL3170Vz7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K2ZwNUxMjc_20ZcH7ohneGNr63im_cUGT78fMzE_YBTbAp1Sxkd0fk","Use":null,"X":null,"X5c":[],"X5t":null,"X5tS256":null,"X5u":null,"Y":null,"KeySize":2048,"HasPrivateKey":true,"CryptoProviderFactory":{"CryptoProviderCache":{},"CustomCryptoProvider":null,"CacheSignatureProviders":true,"SignatureProviderObjectPoolCacheSize":16}}