我的应用程序使用ASP.NET成员资格提供程序正确配置并在配置文件中指定密码格式后,用户密码仍以纯文本形式存储,而是存储在哈希值中
我做错了什么?
这是我的webcongfigurationfile
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<connectionStrings>
<add name="db_connection" providerName="System.Data.SqlClient" connectionString="Data Source=192.168.11.10;Integrated Security=true;Initial Catalog=TestDB;User ID=sysad;Password=abc@123_ec"/>
</connectionStrings>
<system.web>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<pages>
<namespaces>
<add namespace="System.Web.Optimization" />
</namespaces>
<controls>
<add assembly="Microsoft.AspNet.Web.Optimization.WebForms" namespace="Microsoft.AspNet.Web.Optimization.WebForms" tagPrefix="webopt" />
<add tagPrefix="ajaxToolkit" assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" />
<add assembly="JuiceUI" namespace="Juice" tagPrefix="juice" />
</controls>
</pages>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login.aspx" timeout="25" />
</authentication>
<membership defaultProvider="Myprovider">
<providers>
<add name="Myprovider"
type="System.Web.Security.SqlMembershipProvider"
passwordFormat="Hashed"
connectionStringName="db_connection"
enablePasswordRetrieval="false"
enablePasswordReset="true"
requiresQuestionAndAnswer="false"
requiresUniqueEmail="false"
maxInvalidPasswordAttempts="3"
minRequiredPasswordLength="7"
minRequiredNonalphanumericCharacters="1"
passwordAttemptWindow="10"
applicationName="" />
</providers>
</membership>
</system.web>
</configuration>
答案 0 :(得分:0)
注意:我没有这方面的工作。
查看http://msdn.microsoft.com/en-us/library/wfdhbte0.aspx以及用于
的名为HashAlgorithmType
的媒体资源
获取或设置用于敏感的加密类型 会员信息。
<membership defaultProvider="Myprovider" hashAlgorithmType="someValue">
“somevalue”可以是SHA1
或MD5
。
对不起,我对这个问题无能为力。这纯粹基于查看MSDN文档。
答案 1 :(得分:0)
在我看来,您的身份验证标记 machinekey标记不完整缺失。阅读以下链接,告诉我们它是如何进行的。我的网站遇到了类似的问题,并且遵循这些教程就像是一个魅力。
我会详细介绍它的午餐时间,所以你可以自己动手:)祝你好运。
编辑:我清楚了解了我对您的身份验证标记的说法。我的意思是你缺少机器密钥标签。创建它的说明与身份验证标记教程位于同一页面上,我将它们混合起来。
以下是您需要的代码:
<configuration>
<system.web>
... Some markup was removed for brevity ...
<machineKey
decryption="AES"
validation="SHA1"
decryptionKey="1513F567EE75F7FB5AC0AC4D79E1D9F25430E3E2F1BCDD3370BCFC4EFC97A541"
validationKey="32CBA563F26041EE5B5FE9581076C40618DCC1218F5F447634EDE8624508A129"
/>
</system.web>
</configuration>
这里列出的密钥来自教程网站,但您需要生成自己的密钥。它们可以使用一些流行的随机密钥生成器之一生成。我建议使用Steve Gibson的Perfect Passwords Web Page。