基于声明的授权 - 如何管理声明

4
在过去的几天里,我一直在努力理解基于声明的授权,并且我有一个严重的问题,即如何将理论知识应用到实际的MVC网站中。 像http://www.codeproject.com/Articles/639458/Claims-Based-Authentication-and-Authorization这样的教程描述了安装和基础知识的过程,但是在如何管理声明方面却很少提及。
假设有一个简单的MVC网站,用于保存有趣驯鹿的图片。它使用Thinktecture.IdentityModel,但可能每个其他的Identitymodel都可以。假设认证已经就位并且正常工作。
 public class ReindeerController : Controller
    {
        //should be accesible to whole world
        public ActionResult AboutReindeers()
        {}
        //should be accessible to users which are supposed to add Reindeers, e.g. an "Admin" (which is a role, I know)
        public ActionResult AddReindeer()
        {}
        //Only for the Site-owner
        public ActionResult DeleteReindeer()
        {}
        //should be accesible to registred users
        public ActionResult Index()
        {}
    }

我有一个UserClaims表,它存储了用户ID、声明的类型(作为URL)和声明的值。但这只是声明的技术基础 - 我想知道是否有一个良好的模式来创建声明并定义用户拥有/需要什么声明。

2个回答

1

请查看这篇(旧的)文章关于认证声明以获得概述。

然后您可以在这里找到更多细节,thinktecture 还有许多其他好的文章。

WIF API 描述应该帮助您填补空白。


非常感谢,我会看一下! - Christian Sauer

0
我有一个UserClaims表,它存储了用户ID、声明类型作为URL和声明的值。
听起来像是一种完全合适的存储声明的方式。你的方法是正确的,也是我会采用的方法。我的建议是不要过度思考这个问题,你已经有了一个很好的解决方案。 :)

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接