Windows Azure的基于角色的身份验证(ACS) [英] Windows Azure Role Based authentication (ACS)

查看:136
本文介绍了Windows Azure的基于角色的身份验证(ACS)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对Windows Azure云中运行的Asp.net mvc4项目了。但到目前为止,还没有任何用户管理的事情。任何一个可以登录(我有一个Windows Live上的单点登录)。
但现在我需要做的最简单的基于角色的认证。

I have a Asp.net mvc4 project running on Windows Azure Cloud already. But so far it hasn't any user management thing. any one can log in(I have a windows live single sign on). But now I need to do the simplest role based authentication.

1.我想要注册用户角色(管理员,用户,内容管理器)/可手动完成。
2.我需要登录时进行身份验证基于角色的用户。

1.I want to register user roles(administrator,user,content manager)/it can be done manually. 2.I need to authenticate users based on roles when they log in .

任何一个可以给我一个提示,或者链接到一个清晰的教程或建议我的任何想法?

Can any one give me a hint, or link to a clear tutorial or suggest me any idea?

推荐答案

最简单的其实是添加由ACS颁发的令牌角色的要求。既然你说你是在手动做这行,现在好了,那么你使用ACS门户网站来创建这些规则。

The simplest is actually to add "role" claims in the token issued by ACS. Since you said you are ok in doing this manually for now, then you'd use the ACS portal to create these rules.

在您的应用程序,你会做平常的事情,像装饰的授权的行为属性,包括角色:

In your app, you'd do the usual thing, like decorate the actions with the "Authorize" attribute, including roles:

[Authorize(Roles="Administrator")]
public ActionResult Index()
{
  var b = User.IsInRole("Manager");
...
}

只要你使用角色声明类型,一切正常。 (这也可以定制的,但它的作品开箱这种方式)。

As long as you use "Role" claim types, everything works. (This can also be customized, but it works out of the box this way).

您将拥有唯一的挑战是由于的LiveID。 LiveID的给你只是一个唯一的标识符。你需要映射与用户专有(例如电子邮件或名称)的标识符的方式。这通常需要两个步骤。你先进行身份验证,并获得唯一的ID,然后你问其信息的用户,并对其进行验证(通过发送例如电子邮件)。

The only challenge you will have is due to LiveID. LiveID gives you just a unique identifier. You need a way of mapping that identifier with a know user (e.g. e-mail or name). This usually requires a two step process. You first authenticate and get the unique id, then you ask the user for its information and validate it (by sending an e-mail for example).

使用任何其他身份提供的,你没有这个问题,因为所有的人给你的电子邮件和名称。

Using any of the other identity providers, you don't have this problem, because all of them give you an e-mail and a name.

编写上述规则是一样容易:

Writing the above mentioned rules is as easy as:


  • 电子邮件:joy@mail.com - >角色:管理员

  • 电子邮件:someone@mail.com - >角色:经理
    ...

如果您有更多的用户数或再大一些规则的门户网站往往不再实用,你将需要别的东西(如使用API​​从您的应用程序,使用脚本,使用类似的 auth10 等)

If you have a larger number of users or a larger number of rules then the portal is often no longer practical and you will need something else (e.g. use the API from your app, use scripting, use a tool like auth10, etc.)

这篇关于Windows Azure的基于角色的身份验证(ACS)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆