-
-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
github-actions
committed
Nov 17, 2022
1 parent
a551310
commit 2441a79
Showing
36 changed files
with
704 additions
and
621 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
sample/Aguacongas.TheIdServer.WsFederationSample/Extensions/ApplicationBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
...e/Aguacongas.TheIdServer.WsFederationSample/Extensions/WebApplicationBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
42
sample/Aguacongas.TheIdServer.WsFederationSample/Program.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
sample/MultiTiers/Aguacongas.TheIdServer.Api/Extensions/ApplicationBuilderExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
Oops, something went wrong.