Role based authorization in asp.net web api using ad access token -


i need implement role based authorization asp .net web api native client application access token sent in header , when give [authorize] attribute web api working fine,but when give [authorize(role="admin")] giving unauthorized error, whenever check role in claims null.

my startup.cs is

 public void configuration(iappbuilder app)         {             app.usewindowsazureactivedirectorybearerauthentication(             new windowsazureactivedirectorybearerauthenticationoptions             {                 audience = configurationmanager.appsettings["ida:audience"],                 tenant = configurationmanager.appsettings["ida:tenant"],                            });          } 

and have applied authorize attribute method

   [authorize]         [httpget]         public async task<userdetails> testauthorization()         {                     string upn = claimsprincipal.current.findfirst(claimtypes.name).value;             string tenantid = claimsprincipal.current.findfirst("http://schemas.microsoft.com/identity/claims/tenantid").value;             var role = claimsprincipal.current.findfirst(claimtypes.role);            return null;         } 

here role value null

please me on this


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -