Skip to content

Commit acd78ae

Browse files
authored
Merge branch 'master' into pmaytak/miw-0.2.0
2 parents 48f60e2 + 24277ec commit acd78ae

File tree

4 files changed

+6
-23
lines changed

4 files changed

+6
-23
lines changed

1-Call-MSGraph/daemon-console/daemon-console.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.1.0" />
1515
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.1.0" />
1616
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.1.0" />
17-
<PackageReference Include="Microsoft.Identity.Client" Version="4.16.0" />
17+
<PackageReference Include="Microsoft.Identity.Client" Version="4.16.1" />
1818
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
1919
</ItemGroup>
2020

2-Call-OwnApi/TodoList-WebApi/Controllers/TodoListController.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
using Microsoft.AspNetCore.Authorization;
66
using Microsoft.AspNetCore.Http;
77
using Microsoft.AspNetCore.Mvc;
8+
using Microsoft.Identity.Web.Resource;
89
using Newtonsoft.Json;
910
using TodoList_WebApi.Models;
1011

@@ -31,9 +32,9 @@ public TodoListController()
3132

3233
// GET: api/todolist
3334
[HttpGet]
34-
[Authorize(Policy = "DaemonAppRole")]
3535
public IActionResult Get()
3636
{
37+
HttpContext.ValidateAppRole("DaemonAppRole");
3738
return Ok(TodoStore.Values);
3839
}
3940
}

2-Call-OwnApi/TodoList-WebApi/Startup.cs

Lines changed: 2 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,8 @@ public Startup(IConfiguration configuration)
2121
// This method gets called by the runtime. Use this method to add services to the container.
2222
public void ConfigureServices(IServiceCollection services)
2323
{
24-
// This is required to be instantiated before the OpenIdConnectOptions starts getting configured.
25-
// By default, the claims mapping will map claim names in the old format to accommodate older SAML applications.
26-
// 'http://schemas.microsoft.com/ws/2008/06/identity/claims/role' instead of 'roles'
27-
// This flag ensures that the ClaimsIdentity claims collection will be built from the claims in the token
28-
JwtSecurityTokenHandler.DefaultMapInboundClaims = false;
29-
30-
services.AddProtectedWebApi(Configuration);
31-
32-
// Additional configuration
33-
services.Configure<JwtBearerOptions>(JwtBearerDefaults.AuthenticationScheme, options =>
34-
{
35-
options.TokenValidationParameters.RoleClaimType = "roles";
36-
});
37-
38-
// Creating policies that wraps the authorization requirements.
39-
services.AddAuthorization(options =>
40-
{
41-
// The application should only allow tokens which roles claim contains "DaemonAppRole")
42-
options.AddPolicy("DaemonAppRole", policy => policy.RequireRole("DaemonAppRole"));
43-
});
24+
services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)
25+
.AddMicrosoftWebApi(Configuration);
4426

4527
services.AddControllers();
4628
}

2-Call-OwnApi/daemon-console/Daemon-Console.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
1515
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="3.0.0" />
1616
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
17-
<PackageReference Include="Microsoft.Identity.Client" Version="4.16.0" />
17+
<PackageReference Include="Microsoft.Identity.Client" Version="4.16.1" />
1818
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
1919
</ItemGroup>
2020

0 commit comments

Comments
 (0)