0

我的应用程序使用 ASP.NET 成员资格提供程序。正确配置并在配置文件中指定密码格式后,用户密码仍以纯文本形式存储,而不是散列值。
我究竟做错了什么?
这是我的网络配置文件

<?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>
4

2 回答 2

0

在我看来,您的身份验证标签machinekey 标签不完整。阅读以下链接,让我们知道它是如何进行的。我的网站也有类似的问题,遵循这些教程就像一个魅力。

http://www.asp.net/web-forms/tutorials/security/introduction/forms-authentication-configuration-and-advanced-topics-vb

我会更详细地介绍,但它是午餐时间,所以你一个人:) 祝你好运。


编辑:我划掉了我所说的关于您的身份验证标签的内容。我的意思是你的机器钥匙标签丢失了。创建它的说明与身份验证标签教程在同一页面上,我将它们混合在一起。

这是您需要的代码:

<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

于 2012-12-28T17:21:33.233 回答
0

注意:我还没有研究过这个。

看看http://msdn.microsoft.com/en-us/library/wfdhbte0.aspx和一个名为的HashAlgorithmType属性

获取或设置用于敏感成员信息的加密类型。

<membership defaultProvider="Myprovider" hashAlgorithmType="someValue">
“somevalue”可以是SHA1MD5

对不起,我对此无能为力。这纯粹是基于查看 MSDN 文档。

于 2012-12-28T15:13:27.680 回答