Skip to content

Commit

Permalink
refactor: suppress warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
github-actions committed Nov 17, 2022
1 parent a551310 commit 2441a79
Show file tree
Hide file tree
Showing 36 changed files with 704 additions and 621 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Project: Aguafrommars/TheIdServer
// Copyright (c) 2022 @Olivier Lefebvre

namespace Microsoft.AspNetCore.Builder
{
public static class ApplicationBuilderExtensions
{
public static IApplicationBuilder UseWsFederationSample(this IApplicationBuilder app)
=> app.UseDeveloperExceptionPage()
.UseHttpsRedirection()
.UseStaticFiles()
.UseRouting()
.UseAuthentication()
.UseAuthorization()
.UseEndpoints(enpoints => enpoints.MapDefaultControllerRoute());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Project: Aguafrommars/TheIdServer
// Copyright (c) 2022 @Olivier Lefebvre

using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Authentication.WsFederation;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;

namespace Microsoft.AspNetCore.Builder
{
public static class WebApplicationBuilderExtensions
{
public static WebApplicationBuilder AddWsFederationSample(this WebApplicationBuilder webApplicationBuilder)
{
var services = webApplicationBuilder.Services;
services.AddLogging(options => options.SetMinimumLevel(LogLevel.Debug))
.AddControllersWithViews();

services.AddAuthentication(options =>
{
options.DefaultScheme = CookieAuthenticationDefaults.AuthenticationScheme;
options.DefaultChallengeScheme = WsFederationDefaults.AuthenticationScheme;
})
.AddCookie(options =>
{
options.Cookie.Name = "aspnetcorewsfed";
})
.AddWsFederation(options =>
{
options.MetadataAddress = "https://localhost:5443/wsfederation/metadata";
options.RequireHttpsMetadata = false;
options.Wtrealm = "urn:aspnetcorerp";
options.SignOutWreply = "https://localhost:10315";
options.SkipUnrecognizedRequests = true;
});

return webApplicationBuilder;
}
}
}
42 changes: 12 additions & 30 deletions sample/Aguacongas.TheIdServer.WsFederationSample/Program.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,17 @@
// Project: Aguafrommars/TheIdServer
// Copyright (c) 2022 @Olivier Lefebvre
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Builder;
using Serilog;
using Serilog.Events;
using Serilog.Sinks.SystemConsole.Themes;

namespace Aguacongas.TheIdServer.WsFederationSample
{
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Build().Run();
}
var builder = WebApplication.CreateBuilder(args);

public static IHostBuilder BuildWebHost(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>()
.UseSerilog((context, configuration) =>
{
configuration
.MinimumLevel.Debug()
.MinimumLevel.Override("Microsoft", LogEventLevel.Information)
.MinimumLevel.Override("System", LogEventLevel.Information)
.MinimumLevel.Override("Microsoft.AspNetCore.Authentication", LogEventLevel.Information)
.WriteTo.Debug(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}")
.WriteTo.Console(outputTemplate: "[{Timestamp:HH:mm:ss} {Level}] {SourceContext}{NewLine}{Message:lj}{NewLine}{Exception}{NewLine}", theme: AnsiConsoleTheme.Literate);
});
});
}
}
builder.Host.UseSerilog((hostingContext, configuration) =>
configuration.ReadFrom.Configuration(hostingContext.Configuration));

builder.AddWsFederationSample();

var app = builder.Build();

app.UseWsFederationSample();

await app.RunAsync().ConfigureAwait(false);
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@
<CodeAnalysisRuleSet>Aguacongas.TheIdServer.Api.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Data\**" />
<Compile Remove="Models\**" />
<Content Remove="Data\**" />
<Content Remove="Models\**" />
<EmbeddedResource Remove="Data\**" />
<EmbeddedResource Remove="Models\**" />
<None Remove="Data\**" />
<None Remove="Models\**" />
</ItemGroup>

<ItemGroup>
<AdditionalFiles Include="..\..\..\.sonarlint\aguacongas_theidserver\CSharp\SonarLint.xml" Link="SonarLint.xml" />
</ItemGroup>
Expand Down Expand Up @@ -50,8 +61,4 @@
<PackageReference Include="Serilog.Sinks.File" Version="5.0.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.1.1" />
</ItemGroup>
<ItemGroup>
<Folder Include="Data\" />
<Folder Include="Models\" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Project: Aguafrommars/TheIdServer
// Copyright (c) 2022 @Olivier Lefebvre
using Aguacongas.TheIdServer.Admin.Hubs;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Serilog;

namespace Microsoft.AspNetCore.Builder
{
public static class ApplicationBuilderExtensions
{
public static IApplicationBuilder UseTheIdServerApi(this IApplicationBuilder app, IWebHostEnvironment environment)
{
if (environment.IsDevelopment())
{
app.UseDeveloperExceptionPage()
.UseMigrationsEndPoint();
}
else
{
app.UseExceptionHandler("/Home/Error")
.UseHsts();
}

app.UseSerilogRequestLogging()
.UseHttpsRedirection()
.UseResponseCompression()
.UseStaticFiles()
.UseRouting()
.UseAuthentication()
.UseAuthorization()
.UseEndpoints(endpoints =>
{
endpoints.MapAdminApiControllers();
endpoints.MapHub<ProviderHub>("/providerhub");
});

return app;
}
}
}
Original file line number Diff line number Diff line change
@@ -1,66 +1,51 @@
// Project: Aguafrommars/TheIdServer
// Project: Aguafrommars/TheIdServer
// Copyright (c) 2022 @Olivier Lefebvre
using Aguacongas.IdentityServer.Admin.Services;
using Aguacongas.IdentityServer.EntityFramework.Store;
using Aguacongas.IdentityServer.Admin.Services;
using Aguacongas.IdentityServer.Store;
using Aguacongas.TheIdServer.Admin.Hubs;
using Aguacongas.TheIdServer.Authentication;
using Aguacongas.TheIdServer.Authentication;
using Aguacongas.TheIdServer.Data;
using Aguacongas.TheIdServer.Models;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.ResponseCompression;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Newtonsoft.Json;
using Serilog;
using System;
using System.Linq;
using System.Reflection;

namespace Aguacongas.TheIdServer.Api
namespace Microsoft.AspNetCore.Builder
{
public class Startup
public static class WebApplicationBuilderExtensions
{
public IConfiguration Configuration { get; }
public IWebHostEnvironment Environment { get; }

public Startup(IConfiguration configuration, IWebHostEnvironment environment)
{
Configuration = configuration;
Environment = environment;
}

// This method gets called by the runtime. Use this method to add services to the container.
// For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
public static WebApplicationBuilder AddTheIdServerApi(this WebApplicationBuilder webApplicationBuilder)
{
var migrationsAssembly = typeof(Startup).GetTypeInfo().Assembly.GetName().Name;
var connectionString = Configuration.GetConnectionString("DefaultConnection");
var configuration = webApplicationBuilder.Configuration;
var migrationsAssembly = "Aguacongas.TheIdServer.Migrations.SqlServer";
var connectionString = configuration.GetConnectionString("DefaultConnection");

var services = webApplicationBuilder.Services;
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(connectionString))
options.UseSqlServer(connectionString))
.AddTheIdServerAdminEntityFrameworkStores(options =>
options.UseSqlServer(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly)))
.AddConfigurationEntityFrameworkStores(options =>
options.UseSqlServer(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly)))
.AddOperationalEntityFrameworkStores(options =>
options.UseSqlServer(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly)));

var signalRBuilder = services.AddSignalR(options => Configuration.GetSection("SignalR:HubOptions").Bind(options));
if (Configuration.GetValue<bool>("SignalR:UseMessagePack"))
{
signalRBuilder.AddMessagePackProtocol();
}
options.UseSqlServer(connectionString, sql => sql.MigrationsAssembly(migrationsAssembly)));

var signalRBuilder = services.AddSignalR(options => configuration.GetSection("SignalR:HubOptions").Bind(options));
if (configuration.GetValue<bool>("SignalR:UseMessagePack"))
{
signalRBuilder.AddMessagePackProtocol();
}


services.Configure<SendGridOptions>(Configuration)
services.Configure<SendGridOptions>(configuration)
.AddControllersWithViews(options =>
{
options.AddIdentityServerAdminFilters();
})
{
options.AddIdentityServerAdminFilters();
})
.AddNewtonsoftJson(options =>
{
var settings = options.SerializerSettings;
Expand Down Expand Up @@ -95,50 +80,24 @@ public void ConfigureServices(IServiceCollection services)
options.LegacyAudienceValidation = true;
})
.AddDynamic<SchemeDefinition>()
.AddGoogle()
.AddFacebook()
.AddOpenIdConnect()
.AddTwitter()
.AddMicrosoftAccount()
.AddOAuth("OAuth", options =>
{
});


services.AddDatabaseDeveloperPageExceptionFilter()
.AddResponseCompression(opts =>
{
opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
new[] { "application/octet-stream" });
});
}
.AddGoogle()
.AddFacebook()
.AddOpenIdConnect()
.AddTwitter()
.AddMicrosoftAccount()
.AddOAuth("OAuth", options =>
{
});

// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
{
if (Environment.IsDevelopment())
{
app.UseDeveloperExceptionPage()
.UseMigrationsEndPoint();
}
else
{
app.UseExceptionHandler("/Home/Error")
.UseHsts();
}

app.UseSerilogRequestLogging()
.UseHttpsRedirection()
.UseResponseCompression()
.UseStaticFiles()
.UseRouting()
.UseAuthentication()
.UseAuthorization()
.UseEndpoints(endpoints =>
services.AddDatabaseDeveloperPageExceptionFilter()
.AddResponseCompression(opts =>
{
endpoints.MapAdminApiControllers();
endpoints.MapHub<ProviderHub>("/providerhub");
opts.MimeTypes = ResponseCompressionDefaults.MimeTypes.Concat(
new[] { "application/octet-stream" });
});

return webApplicationBuilder;
}
}
}
31 changes: 11 additions & 20 deletions sample/MultiTiers/Aguacongas.TheIdServer.Api/Program.cs
Original file line number Diff line number Diff line change
@@ -1,26 +1,17 @@
// Project: Aguafrommars/TheIdServer
// Copyright (c) 2022 @Olivier Lefebvre
using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Hosting;
using Microsoft.AspNetCore.Builder;
using Serilog;

namespace Aguacongas.TheIdServer.Api
{
public class Program
{
public static void Main(string[] args)
{
var host = CreateWebHostBuilder(args).Build();
host.Run();
}
var builder = WebApplication.CreateBuilder(args);

public static IWebHostBuilder CreateWebHostBuilder(string[] args)
{
return WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
.UseSerilog((hostingContext, configuration) =>
builder.Host.UseSerilog((hostingContext, configuration) =>
configuration.ReadFrom.Configuration(hostingContext.Configuration));
}
}
}

builder.AddTheIdServerApi();

var app = builder.Build();

app.UseTheIdServerApi(app.Environment);

app.Run();
Loading

0 comments on commit 2441a79

Please sign in to comment.