将用户ID存储在Principal还是Identity中? ASP.Net/OpenID [英] Store user id in Principal or 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存储在标准GenericIdentity
的Name
中.我也想方便地访问用户的数据库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屋!