-
-
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
Jun 11, 2022
1 parent
94fc001
commit 2aab545
Showing
36 changed files
with
722 additions
and
256 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
sample/Aguacongas.TheIdServer.ApiSample/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,37 @@ | ||
// Project: Aguafrommars/TheIdServer | ||
// Copyright (c) 2022 @Olivier Lefebvre | ||
|
||
using Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace Microsoft.AspNetCore.Builder | ||
{ | ||
public static class ApplicationBuilderExtensions | ||
{ | ||
public static IApplicationBuilder UseApiSample(this IApplicationBuilder app, IWebHostEnvironment env) | ||
{ | ||
if (env.IsDevelopment()) | ||
{ | ||
app.UseDeveloperExceptionPage(); | ||
} | ||
|
||
app.UseHttpsRedirection() | ||
.UseCors(configurePolicy => | ||
{ | ||
configurePolicy.WithOrigins("http://localhost:5002") | ||
.AllowAnyMethod() | ||
.AllowAnyHeader(); | ||
}); | ||
|
||
app.UseRouting() | ||
.UseAuthentication() | ||
.UseAuthorization() | ||
.UseEndpoints(endpoints => | ||
{ | ||
endpoints.MapControllers(); | ||
}); | ||
|
||
return app; | ||
} | ||
} | ||
} |
34 changes: 34 additions & 0 deletions
34
sample/Aguacongas.TheIdServer.ApiSample/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,34 @@ | ||
// Project: Aguafrommars/TheIdServer | ||
// Copyright (c) 2022 @Olivier Lefebvre | ||
|
||
using IdentityServer4.AccessTokenValidation; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using System; | ||
|
||
namespace Microsoft.AspNetCore.Builder | ||
{ | ||
public static class WebApplicationBuilderExtensions | ||
{ | ||
public static WebApplicationBuilder AddApiSample(this WebApplicationBuilder webApplicationBuilder) | ||
{ | ||
var services = webApplicationBuilder.Services; | ||
services.AddCors() | ||
.AddAuthorization() | ||
.AddControllers(); | ||
|
||
services.AddAuthentication(IdentityServerAuthenticationDefaults.AuthenticationScheme) | ||
.AddIdentityServerAuthentication(options => | ||
{ | ||
options.Authority = "https://localhost:5443"; | ||
options.RequireHttpsMetadata = false; | ||
options.SupportedTokens = SupportedTokens.Both; | ||
options.ApiName = "api1"; | ||
options.EnableCaching = true; | ||
options.CacheDuration = TimeSpan.FromMinutes(10); | ||
options.LegacyAudienceValidation = true; | ||
}); | ||
|
||
return webApplicationBuilder; | ||
} | ||
} | ||
} |
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,36 +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; | ||
|
||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
namespace Aguacongas.TheIdServer.ApiSample | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
builder.Host.UseSerilog((hostingContext, configuration) => | ||
configuration.ReadFrom.Configuration(hostingContext.Configuration)); | ||
|
||
public static IHostBuilder CreateHostBuilder(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.AddApiSample(); | ||
|
||
var app = builder.Build(); | ||
|
||
app.UseApiSample(builder.Environment); | ||
|
||
await app.RunAsync().ConfigureAwait(false); |
41 changes: 41 additions & 0 deletions
41
sample/Aguacongas.TheIdServer.MvcClient/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 Microsoft.AspNetCore.Hosting; | ||
using Microsoft.Extensions.Hosting; | ||
|
||
namespace Microsoft.AspNetCore.Builder | ||
{ | ||
public static class ApplicationBuilderExtensions | ||
{ | ||
public static IApplicationBuilder UseMvcSample(this IApplicationBuilder app, IWebHostEnvironment env) | ||
{ | ||
if (env.IsDevelopment()) | ||
{ | ||
app.UseDeveloperExceptionPage(); | ||
} | ||
else | ||
{ | ||
app.UseExceptionHandler("/Home/Error"); | ||
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. | ||
app.UseHsts(); | ||
} | ||
app.UseHttpsRedirection() | ||
.UseAuthentication() | ||
.UseStaticFiles() | ||
.UseRouting(); | ||
|
||
app.UseAuthorization(); | ||
|
||
app.UseEndpoints(endpoints => | ||
{ | ||
endpoints.MapControllerRoute( | ||
name: "default", | ||
pattern: "{controller=Home}/{action=Index}/{id?}"); | ||
}); | ||
|
||
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,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.MvcClient | ||
{ | ||
public class Program | ||
{ | ||
public static void Main(string[] args) | ||
{ | ||
CreateHostBuilder(args).Build().Run(); | ||
} | ||
var builder = WebApplication.CreateBuilder(args); | ||
|
||
public static IHostBuilder CreateHostBuilder(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.AddMvcSample(); | ||
|
||
var app = builder.Build(); | ||
|
||
app.UseMvcSample(builder.Environment); | ||
|
||
await app.RunAsync().ConfigureAwait(false); |
51 changes: 0 additions & 51 deletions
51
sample/Aguacongas.TheIdServer.WsFederationSample/Startup.cs
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.