登录后添加额外的数据来验证Cookie的 - MVC 5 [英] Adding Extra Data to Auth Cookie after login - MVC 5

查看:137
本文介绍了登录后添加额外的数据来验证Cookie的 - MVC 5的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个用户登录到我们的网站MVC5后,一个额外的必不可少的步骤。这是因为一些用户访问多个办事处。我得到了一些帮助,如何使用这太问题,<一实施href=\"http://stackoverflow.com/questions/29094551/adding-extra-step-to-asp-net-mvc-authentication\">Adding额外的步骤,ASP.NET MVC认证

一旦用户进行这一步,我需要在藏匿身份验证Cookie他们的办公室选择。


  1. 如何额外的数据存储到身份验证Cookie后,
    登录已经完成?

  2. 在访问一个额外的数据自定义标识类的正确的方法?


解决方案

您可以使用要求,以提供额外的数据。有一个 ClaimsIdentity 类,您可以使用添加额外的索赔,并考虑索赔。您还可以使用过滤器操作方法控制器来只有与具体主张使用。

我没有详细解释这一点,但跟着你找到一些免费章节从电子书从A preSS(100页)的链接不错。具体章节是第15章,但你会获得在整个身份管理一个很好的洞察力在整个文档阅读。

从A preSS <免费电子书页面/ p>

We have an extra mandatory step after a user signs into our MVC5 site. This is because some users have access to multiple offices. I got some help with how to enforce with this SO question, Adding extra step to ASP.NET MVC authentication

Once the user has performed that step I need to stash their office selection in the authentication cookie.

  1. How do I store extra data into the authentication cookie, after Login has been completed?
  2. Is the correct method of accessing that extra data a custom Identity class?

解决方案

You can use claims to provide extra data. There is a ClaimsIdentity class, that you can use to add extra claims and look into the claims. You can also use Filters for Action Methods and Controllers to be only accessible with specific claims.

I'm not good in explaining this in detail, but following the link you find some free chapters from an eBook from Apress (100 pages). The specific chapter would be chapter 15, but you'll gain a good insight in the whole Identity Management reading through the whole document.

Free eBook Pages from Apress

这篇关于登录后添加额外的数据来验证Cookie的 - MVC 5的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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