mirror of
https://github.com/ditkrg/AuthorizationServerDemos.git
synced 2026-01-23 03:36:52 +00:00
Merge branch 'master' of https://github.com/ditdevtools/AuthorizationServerDemos
This commit is contained in:
commit
516177f433
@ -57,7 +57,7 @@ namespace OidcSamples.AuthorizationServer
|
|||||||
RequireClientSecret = false,
|
RequireClientSecret = false,
|
||||||
RedirectUris =
|
RedirectUris =
|
||||||
{
|
{
|
||||||
"https://localhost:3000/signin-oidc"
|
"http://localhost:3000/signin-oidc"
|
||||||
},
|
},
|
||||||
AllowedScopes =
|
AllowedScopes =
|
||||||
{
|
{
|
||||||
@ -70,7 +70,7 @@ namespace OidcSamples.AuthorizationServer
|
|||||||
RequirePkce = true,
|
RequirePkce = true,
|
||||||
PostLogoutRedirectUris =
|
PostLogoutRedirectUris =
|
||||||
{
|
{
|
||||||
"https://localhost:3000/signout-callback-oidc"
|
"http://localhost:3000/signout-callback-oidc"
|
||||||
},
|
},
|
||||||
|
|
||||||
RequireConsent = false,
|
RequireConsent = false,
|
||||||
@ -85,7 +85,7 @@ namespace OidcSamples.AuthorizationServer
|
|||||||
AllowedGrantTypes = GrantTypes.Code,
|
AllowedGrantTypes = GrantTypes.Code,
|
||||||
RedirectUris =
|
RedirectUris =
|
||||||
{
|
{
|
||||||
"https://localhost:7001/signin-oidc"
|
"http://localhost:7000/signin-oidc"
|
||||||
},
|
},
|
||||||
AllowedScopes =
|
AllowedScopes =
|
||||||
{
|
{
|
||||||
@ -102,7 +102,7 @@ namespace OidcSamples.AuthorizationServer
|
|||||||
RequirePkce = true,
|
RequirePkce = true,
|
||||||
PostLogoutRedirectUris =
|
PostLogoutRedirectUris =
|
||||||
{
|
{
|
||||||
"https://localhost:7001/signout-callback-oidc"
|
"http://localhost:7000/signout-callback-oidc"
|
||||||
},
|
},
|
||||||
|
|
||||||
RequireConsent = false,
|
RequireConsent = false,
|
||||||
|
|||||||
@ -6,7 +6,7 @@
|
|||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
},
|
},
|
||||||
"applicationUrl": "https://localhost:10000"
|
"applicationUrl": "http://localhost:10000"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -3,8 +3,10 @@
|
|||||||
|
|
||||||
|
|
||||||
using IdentityServerHost.Quickstart.UI;
|
using IdentityServerHost.Quickstart.UI;
|
||||||
|
using Microsoft.AspNetCore.Authentication.Cookies;
|
||||||
using Microsoft.AspNetCore.Builder;
|
using Microsoft.AspNetCore.Builder;
|
||||||
using Microsoft.AspNetCore.Hosting;
|
using Microsoft.AspNetCore.Hosting;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
@ -24,6 +26,7 @@ namespace OidcSamples.AuthorizationServer
|
|||||||
{
|
{
|
||||||
services.AddControllersWithViews();
|
services.AddControllersWithViews();
|
||||||
|
|
||||||
|
|
||||||
// Dirty Hack: Disable verifying SSL certificates 😬
|
// Dirty Hack: Disable verifying SSL certificates 😬
|
||||||
ServicePointManager.ServerCertificateValidationCallback +=
|
ServicePointManager.ServerCertificateValidationCallback +=
|
||||||
(sender, cert, chain, sslPolicyErrors) => true;
|
(sender, cert, chain, sslPolicyErrors) => true;
|
||||||
@ -59,6 +62,11 @@ namespace OidcSamples.AuthorizationServer
|
|||||||
app.UseDeveloperExceptionPage();
|
app.UseDeveloperExceptionPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
app.UseCookiePolicy(new CookiePolicyOptions
|
||||||
|
{
|
||||||
|
MinimumSameSitePolicy = SameSiteMode.Lax
|
||||||
|
});
|
||||||
|
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
|
||||||
|
|||||||
@ -20,7 +20,7 @@
|
|||||||
"commandName": "Project",
|
"commandName": "Project",
|
||||||
"dotnetRunMessages": "true",
|
"dotnetRunMessages": "true",
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"applicationUrl": "https://localhost:7001;http://localhost:7000",
|
"applicationUrl": "http://localhost:7000",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development",
|
"ASPNETCORE_ENVIRONMENT": "Development",
|
||||||
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
|
"ASPNETCORE_HOSTINGSTARTUPASSEMBLIES": "Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation"
|
||||||
|
|||||||
@ -8,6 +8,7 @@ using Microsoft.AspNetCore.HttpsPolicy;
|
|||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using Microsoft.Extensions.Hosting;
|
using Microsoft.Extensions.Hosting;
|
||||||
|
using Microsoft.IdentityModel.Logging;
|
||||||
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
using Microsoft.IdentityModel.Protocols.OpenIdConnect;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
using Microsoft.Net.Http.Headers;
|
using Microsoft.Net.Http.Headers;
|
||||||
@ -31,6 +32,8 @@ namespace OidcSamples.TaxApp
|
|||||||
// This method gets called by the runtime. Use this method to add services to the container.
|
// This method gets called by the runtime. Use this method to add services to the container.
|
||||||
public void ConfigureServices(IServiceCollection services)
|
public void ConfigureServices(IServiceCollection services)
|
||||||
{
|
{
|
||||||
|
IdentityModelEventSource.ShowPII = true;
|
||||||
|
|
||||||
// Dirty Hack: Disable verifying SSL certificates 😬
|
// Dirty Hack: Disable verifying SSL certificates 😬
|
||||||
ServicePointManager.ServerCertificateValidationCallback +=
|
ServicePointManager.ServerCertificateValidationCallback +=
|
||||||
(sender, cert, chain, sslPolicyErrors) => true;
|
(sender, cert, chain, sslPolicyErrors) => true;
|
||||||
@ -48,7 +51,7 @@ namespace OidcSamples.TaxApp
|
|||||||
.AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, options =>
|
.AddOpenIdConnect(OpenIdConnectDefaults.AuthenticationScheme, options =>
|
||||||
{
|
{
|
||||||
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
|
options.SignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
|
||||||
options.Authority = "https://localhost:10000/";
|
options.Authority = "http://localhost:10000/";
|
||||||
options.ClientId = "tax-asp-net-core-app";
|
options.ClientId = "tax-asp-net-core-app";
|
||||||
options.ResponseType = OpenIdConnectResponseType.Code;
|
options.ResponseType = OpenIdConnectResponseType.Code;
|
||||||
options.UsePkce = true;
|
options.UsePkce = true;
|
||||||
@ -64,6 +67,8 @@ namespace OidcSamples.TaxApp
|
|||||||
options.GetClaimsFromUserInfoEndpoint = true;
|
options.GetClaimsFromUserInfoEndpoint = true;
|
||||||
|
|
||||||
options.TokenValidationParameters.NameClaimType = "name";
|
options.TokenValidationParameters.NameClaimType = "name";
|
||||||
|
|
||||||
|
options.RequireHttpsMetadata = false;
|
||||||
});
|
});
|
||||||
|
|
||||||
services.AddHttpContextAccessor();
|
services.AddHttpContextAccessor();
|
||||||
@ -72,14 +77,14 @@ namespace OidcSamples.TaxApp
|
|||||||
// create an HttpClient used for accessing the API
|
// create an HttpClient used for accessing the API
|
||||||
services.AddHttpClient("APIClient", client =>
|
services.AddHttpClient("APIClient", client =>
|
||||||
{
|
{
|
||||||
client.BaseAddress = new Uri("https://localhost:6001/");
|
client.BaseAddress = new Uri("http://localhost:6000/");
|
||||||
client.DefaultRequestHeaders.Clear();
|
client.DefaultRequestHeaders.Clear();
|
||||||
client.DefaultRequestHeaders.Add(HeaderNames.Accept, "application/json");
|
client.DefaultRequestHeaders.Add(HeaderNames.Accept, "application/json");
|
||||||
}).AddHttpMessageHandler<BearerTokenHandler>();
|
}).AddHttpMessageHandler<BearerTokenHandler>();
|
||||||
|
|
||||||
services.AddHttpClient("IDPClient", client =>
|
services.AddHttpClient("IDPClient", client =>
|
||||||
{
|
{
|
||||||
client.BaseAddress = new Uri("https://localhost:5003/");
|
client.BaseAddress = new Uri("http://localhost:10000/");
|
||||||
client.DefaultRequestHeaders.Clear();
|
client.DefaultRequestHeaders.Clear();
|
||||||
client.DefaultRequestHeaders.Add(HeaderNames.Accept, "application/json");
|
client.DefaultRequestHeaders.Add(HeaderNames.Accept, "application/json");
|
||||||
});
|
});
|
||||||
@ -99,7 +104,11 @@ namespace OidcSamples.TaxApp
|
|||||||
app.UseHsts();
|
app.UseHsts();
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseCookiePolicy(new CookiePolicyOptions
|
||||||
|
{
|
||||||
|
MinimumSameSitePolicy = Microsoft.AspNetCore.Http.SameSiteMode.Lax
|
||||||
|
});
|
||||||
|
|
||||||
app.UseStaticFiles();
|
app.UseStaticFiles();
|
||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
|||||||
@ -22,7 +22,7 @@
|
|||||||
"dotnetRunMessages": "true",
|
"dotnetRunMessages": "true",
|
||||||
"launchBrowser": true,
|
"launchBrowser": true,
|
||||||
"launchUrl": "swagger",
|
"launchUrl": "swagger",
|
||||||
"applicationUrl": "https://localhost:6001;http://localhost:6000",
|
"applicationUrl": "http://localhost:6000",
|
||||||
"environmentVariables": {
|
"environmentVariables": {
|
||||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||||
}
|
}
|
||||||
|
|||||||
@ -80,8 +80,9 @@ namespace OidcSamples.TrafficPoliceApi
|
|||||||
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
options.DefaultChallengeScheme = JwtBearerDefaults.AuthenticationScheme;
|
||||||
}).AddJwtBearer(options =>
|
}).AddJwtBearer(options =>
|
||||||
{
|
{
|
||||||
options.Authority = "https://localhost:10000";
|
options.Authority = "http://localhost:10000";
|
||||||
options.Audience = "traffic-police-api";
|
options.Audience = "traffic-police-api";
|
||||||
|
options.RequireHttpsMetadata = false;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,9 +96,12 @@ namespace OidcSamples.TrafficPoliceApi
|
|||||||
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "OidcSamples.TrafficPoliceApi v1"));
|
app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "OidcSamples.TrafficPoliceApi v1"));
|
||||||
}
|
}
|
||||||
|
|
||||||
app.UseCors("Default");
|
app.UseCookiePolicy(new CookiePolicyOptions
|
||||||
|
{
|
||||||
|
MinimumSameSitePolicy = Microsoft.AspNetCore.Http.SameSiteMode.Lax
|
||||||
|
});
|
||||||
|
|
||||||
app.UseHttpsRedirection();
|
app.UseCors("Default");
|
||||||
|
|
||||||
app.UseRouting();
|
app.UseRouting();
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user