Creating a AuthorizeAttribute - what do I need to know?

前端 未结 3 1732
离开以前
离开以前 2020-12-28 20:44

Here are my requirements:

  • I\'ll be adding users to N amount of roles; defined in a database.

  • I need to protect each controller action with

3条回答
  •  再見小時候
    2020-12-28 21:10

    There are a bunch of ways to handle this. Darin's method and blowdarts (both very skilled individuals - one of them is a security author as well) are decent in the link you provided.

    One thing to watch out for is the cache. If you use server side outputcache caching, you may inadvertently cache something for one user that gets returned to another user. Please see:

    OutputCache and Authorize filters in MVC3

    and

    Why can't I combine [Authorize] and [OutputCache] attributes when using Azure cache (.NET MVC3 app)?

    and

    MVC Custom Authentication, Authorization, and Roles Implementation

    for additional info on that and how to handle caching if you are using an authorize attribute.

提交回复
热议问题