Skip to content

Commit

Permalink
Update claims
Browse files Browse the repository at this point in the history
  • Loading branch information
damienbod committed Apr 11, 2024
1 parent 6bfcd52 commit eed271b
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace WebApiWithRoles.Controllers;

[Authorize(Policy = "p-web-api-with-roles-admin")]
[Authorize(Policy = "ValidateAccessTokenPolicy")]
[AuthorizeForScopes(Scopes = new string[] { "api://5511b8d6-4652-4f2f-9643-59c61234e3c7/access_as_user" })]
[AuthorizeForScopes(Scopes = ["api://5511b8d6-4652-4f2f-9643-59c61234e3c7/access_as_user"])]
[ApiController]
[Route("api/[controller]")]
public class AdminDataController : ControllerBase
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace WebApiWithRoles.Controllers;

[Authorize(Policy = "p-web-api-with-roles-student")]
[Authorize(Policy = "ValidateAccessTokenPolicy")]
[AuthorizeForScopes(Scopes = new string[] { "api://5511b8d6-4652-4f2f-9643-59c61234e3c7/access_as_user" })]
[AuthorizeForScopes(Scopes = ["api://5511b8d6-4652-4f2f-9643-59c61234e3c7/access_as_user"])]
[ApiController]
[Route("api/[controller]")]
public class StudentDataController : ControllerBase
Expand Down
2 changes: 1 addition & 1 deletion AppRoles/WebApiWithRoles/Controllers/UserDataController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace WebApiWithRoles.Controllers;

[Authorize(Policy = "p-web-api-with-roles-user")]
[Authorize(Policy = "ValidateAccessTokenPolicy")]
[AuthorizeForScopes(Scopes = new string[] { "api://5511b8d6-4652-4f2f-9643-59c61234e3c7/access_as_user" })]
[AuthorizeForScopes(Scopes = ["api://5511b8d6-4652-4f2f-9643-59c61234e3c7/access_as_user"])]
[ApiController]
[Route("api/[controller]")]
public class UserDataController : ControllerBase
Expand Down
6 changes: 3 additions & 3 deletions AppRoles/WebApiWithRoles/Program.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

using Microsoft.AspNetCore.Authentication.JwtBearer;
using Microsoft.AspNetCore.Authentication.OpenIdConnect;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.Identity.Web;
using Microsoft.IdentityModel.JsonWebTokens;
using Microsoft.OpenApi.Models;
using System.IdentityModel.Tokens.Jwt;

var builder = WebApplication.CreateBuilder(args);

Expand Down Expand Up @@ -105,7 +104,8 @@

var app = builder.Build();

JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();

JsonWebTokenHandler.DefaultInboundClaimTypeMap.Clear();
// IdentityModelEventSource.ShowPII = true;

if (app.Environment.IsDevelopment())
Expand Down
4 changes: 2 additions & 2 deletions AppRoles/WebAppWithRoles/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using Microsoft.AspNetCore.Mvc.Authorization;
using Microsoft.Identity.Web;
using Microsoft.Identity.Web.UI;
using System.IdentityModel.Tokens.Jwt;
using Microsoft.IdentityModel.JsonWebTokens;
using WebAppWithRoles;

var builder = WebApplication.CreateBuilder(args);
Expand Down Expand Up @@ -43,7 +43,7 @@

var app = builder.Build();

JwtSecurityTokenHandler.DefaultInboundClaimTypeMap.Clear();
JsonWebTokenHandler.DefaultInboundClaimTypeMap.Clear();
// IdentityModelEventSource.ShowPII = true;

if (app.Environment.IsDevelopment())
Expand Down

0 comments on commit eed271b

Please sign in to comment.