小编Tom*_*Tom的帖子

ASP.NET Web API role based authorization based on route parameter

I'm using roles in my ASP.NET Web API 2 project to limit access to certain resources.

Now I have the following scenario: A clubmanager can only do a GET for a club that he manages. A clubmanager should not be authorized to access clubs that he does not manage.

This is the method that gets a club:

[Authorize(Roles = "ClubManager")]
[Route("{clubId}")]
public Club GetClub(int clubId)
Run Code Online (Sandbox Code Playgroud)

As you can see I only allow a user with the role "ClubManager" to access …

c# authorize asp.net-web-api2

5
推荐指数
1
解决办法
3031
查看次数

标签 统计

asp.net-web-api2 ×1

authorize ×1

c# ×1