将用户ID存储在Principal还是Identity中? ASP.Net/OpenID [英] Store user id in Principal or Identity? ASP.Net/OpenID

查看:102
本文介绍了将用户ID存储在Principal还是Identity中? ASP.Net/OpenID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用表单身份验证的ASP.Net MVC Web应用程序.我正在使用OpenID进行身份验证.

I have an ASP.Net MVC web application using forms authentication. I am using OpenID for authentication.

此刻,我将openID url存储在标准GenericIdentityName中.我也想方便地访问用户的数据库ID.

At the moment the moment I'm storing the openID url inside the Name of the standard GenericIdentity. I would also like to have easy access to the database id for the user.

我可以通过覆盖Application_AuthenticateRequest函数来创建自定义提供程序或身份.

I can make a custom provider or identity by overriding the Application_AuthenticateRequest function.

我的问题是用户的数据库uid应该进入主体还是身份?

My question is should the database uid for the user go into the principal or the identity?

Identity的Name属性应该是openid网址(用户可以有很多,但我想在每个页面上显示它)还是数据库uid?

Should the Name property of the Identity be the openid url (a user can have many of these but I would like to display it on every page) or database uid?

推荐答案

我现在正在考虑只将用户ID存储在Identity中,并保留到Session中的openid网址上.

I'm thinking now that I should just store the user id in the Identity and hang on to the openid url in the Session.

这样,我就不需要自定义标识或主体.

That way I won't need a custom identity or principal.

这篇关于将用户ID存储在Principal还是Identity中? ASP.Net/OpenID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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