WIP separation Web et API
This commit is contained in:
parent
1d6cad7bef
commit
49826eae4a
55 changed files with 68 additions and 95 deletions
|
|
@ -10,43 +10,43 @@ public class Startup
|
|||
{
|
||||
public void ConfigureServices(IServiceCollection services)
|
||||
{
|
||||
|
||||
services.AddControllersWithViews();
|
||||
|
||||
JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
|
||||
|
||||
services.AddAuthentication(options =>
|
||||
{
|
||||
options.DefaultScheme = "Cookies";
|
||||
options.DefaultChallengeScheme = "Yavsc";
|
||||
})
|
||||
.AddCookie("Cookies")
|
||||
.AddOpenIdConnect("Yavsc", options =>
|
||||
{
|
||||
options.Authority = "https://localhost:5001";
|
||||
options.ClientId = "mvc";
|
||||
options.ClientSecret = "49C1A7E1-0C79-4A89-A3D6-A37998FB86B0";
|
||||
options.ResponseType = "code";
|
||||
options.UsePkce = true;
|
||||
options.Scope.Clear();
|
||||
options.Scope.Add("openid");
|
||||
options.Scope.Add("profile");
|
||||
options.Scope.Add("email");
|
||||
options.Scope.Add("offline_access");
|
||||
options.Scope.Add("scope2");
|
||||
|
||||
options.GetClaimsFromUserInfoEndpoint = true;
|
||||
options.SaveTokens = true;
|
||||
options.ClaimActions.MapUniqueJsonKey("http://schemas.microsoft.com/ws/2008/06/identity/claims/role", "http://schemas.microsoft.com/ws/2008/06/identity/claims/role");
|
||||
|
||||
options.ClaimActions.MapUniqueJsonKey("role", "http://schemas.microsoft.com/ws/2008/06/identity/claims/role");
|
||||
options.ClaimActions.MapUniqueJsonKey("roles", "http://schemas.microsoft.com/ws/2008/06/identity/claims/role");
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
services
|
||||
.AddAuthentication(options =>
|
||||
{
|
||||
NameClaimType = "name",
|
||||
RoleClaimType = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
|
||||
};
|
||||
options.DefaultScheme = "Cookies";
|
||||
options.DefaultChallengeScheme = "oidc";
|
||||
})
|
||||
.AddCookie("Cookies")
|
||||
.AddOpenIdConnect("oidc", options =>
|
||||
{
|
||||
options.Authority = "https://localhost:5001";
|
||||
|
||||
options.ClientId = "mvc";
|
||||
options.ClientSecret = "49C1A7E1-0C79-4A89-A3D6-A37998FB86B0";
|
||||
options.ResponseType = "code";
|
||||
|
||||
options.Scope.Add("scope2");
|
||||
|
||||
options.SaveTokens = true;
|
||||
|
||||
options.GetClaimsFromUserInfoEndpoint = true;
|
||||
options.SaveTokens = true;
|
||||
options.ClaimActions.MapUniqueJsonKey(
|
||||
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role",
|
||||
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role");
|
||||
options.ClaimActions.MapUniqueJsonKey("role",
|
||||
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role");
|
||||
options.ClaimActions.MapUniqueJsonKey("roles",
|
||||
"http://schemas.microsoft.com/ws/2008/06/identity/claims/role");
|
||||
options.TokenValidationParameters = new TokenValidationParameters
|
||||
{
|
||||
NameClaimType = "name",
|
||||
RoleClaimType = "http://schemas.microsoft.com/ws/2008/06/identity/claims/role"
|
||||
};
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue