MVC 5当前声称autorization和更新索赔 [英] MVC 5 current claims autorization and updating claims

查看:275
本文介绍了MVC 5当前声称autorization和更新索赔的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有2个关于索赔的问题:

1)在.NET 4.5和MVC 5如何做微软实现autorization,当你在控制器AuthorizeAttirubte设置,它检查数据库来获取用户的角色?或者,它采用了索赔?

我读的地方,微软使用数据库的每个时间来验证的作用,并建议他们写了一个新的AuthorizeAttribute实行声明身份验证。

这是我在谈论的文章: HTTP: //kevin-junghans.blogspot.be/2013/10/improving-performance-of.html

或者是过时,现在微软使用的角色要求?

2)关于索赔的更新第二个问题:

想象一下,当用户登录时,我把他的显示名称索赔。用户必须改变他的显示名称的能力,所以他改变了,但他仍然认为他的旧的显示名称,直到他在网站reasigns。

难道是正确的以某种方式更新索赔....?怎么办呢?


解决方案

  1. 的属性授权使用过的东西像IsAuthenticated /的isUserInRole,间接地看着索赔User.Identity。数据库访问是基于当在cookie中的符号被刷新,而不是在authorize校验,所以其正交

  2. 当cookie中的符号产生(数据库命中)索赔被更新。要强制要求的更新,你可以辞职,迫使更新用户。

I have 2 questions regarding the claims:

1) In .Net 4.5 and MVC 5 how does the microsoft implements the autorization, when you set on controller AuthorizeAttirubte, does it check the database to get the user role? Or it uses the claims?

I've read somewhere that microsoft uses database each time to verify the role, and they advised to write a new AuthorizeAttribute to implement claims authentication.

This is the article i'm talking about: http://kevin-junghans.blogspot.be/2013/10/improving-performance-of.html

Or is it outdated and now microsoft uses the roles in claims?

2) Second question regarding the update of claims:

Imagine when user logs in, I set his display name as a claim. The user has ability to change his display name, so he changes it, but he still sees his old display name, untill he reasigns in the webiste.

Would it be correct to somehow update the claim ....? And how to do it?

解决方案

  1. The authorize attribute is using things off the User.Identity like IsAuthenticated/IsUserInRole, which indirectly looks at claims. Database access is based on when the sign in cookie is refreshed as opposed to the authorize check, so its orthogonal.
  2. Claims are updated when the sign in cookie is generated (database hit). To force an update of the claims, you can just resign in the user which forces the update.

这篇关于MVC 5当前声称autorization和更新索赔的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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