MVC 5 当前声明自动化和更新声明 [英] MVC 5 current claims autorization and updating claims

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

问题描述

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

I have 2 questions regarding the claims:

1) 在 .Net 4.5 和 MVC 5 中,微软如何实现授权,当您在控制器 AuthorizeAttirubte 上设置时,它是否检查数据库以获取用户角色?或者它使用声明?

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?

我在某处读到微软每次都使用数据库来验证角色,他们建议编写一个新的 AuthorizeAttribute 来实现声明身份验证.

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.

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

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) 关于索赔更新的第二个问题:

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. authorize 属性使用了 User.Identity 之外的东西,比如 IsAuthenticated/IsUserInRole,它间接地查看声明.数据库访问基于登录 cookie 的刷新时间,而不是授权检查,因此是正交的.
  2. 声明在生成登录 cookie 时更新(数据库命中).要强制更新声明,您只需退出强制更新的用户即可.

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

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