维护用户登录和信息的安全数据库?

发布于 2024-09-11 15:17:56 字数 158 浏览 3 评论 0原文

我想在我正在构建的慈善网站上有一个登录表单(这是为了朋友,我正在旅途中学习),并且我想知道我应该学习哪些语言/软件来构建用于用户登录和信息的数据库?注意:对于具有中等编程经验的人来说,它必须是安全的并且相对简单易学。

更新:我知道 CMS 提供了很好的登录工具等,但我想自己完成这一切。

I want to have a login form on a charity website I am building (it's for a friend, and I'm learning on the go), and I want to know what languages/software should I learn to build databases for user logins and info? Note: it HAS to be secure and relatively simple to learn for someone with moderate programming experience.

Update: I understand that CMSs offer good tools for logins etc. but I want to do this all by myself.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

月下凄凉 2024-09-18 15:17:57

您可以做的最简单的事情是在将密码输入数据库之前对其进行哈希处理并应用盐。 “邪恶的跳蚤”在另一个问题中有一个很好的答案这里

您是否考虑过购买现成的 CMS?大多数像样的 CMS 应该包含一个简单的慈善网站所需的所有功能。它还将为您的登录表单问题提供可靠的解决方案。

编辑

至于使用什么语言。只要您对此感到满意并愿意投入时间和精力,这实际上并不是很重要。它在您的个人资料中表明您希望学习 PHP。看起来用 PHP 编写登录表单将是一个很好的起点。至于数据库后端。再说一次,这并不重要。只是请不要使用 MS Access。大多数 PHP 开发人员(假设)似乎都使用 MySQL,因为它通常包含在 PHP Web 主机中。

关于安全性,散列和向密码添加盐是您可以做的最简单的事情。您可以执行以下操作:

  • 用户单击注册链接
  • 使用 SSL 调出注册表单
  • 一旦用户单击提交按钮
  • 哈希密码。加盐。存储在数据库中。在哈希密码中添加盐可以防止攻击者使用 rainbow 表 暴力破解您的密码。请查看此处,了解负责散列密码的函数。
  • 您还可以强制用户创建具有特定规则的密码。例如,要求所有密码大于 6 个字符、至少一个数字等...

一旦用户需要登录,您可以执行类似以下操作:

  • 获取用户名并对其进行清理。记住永远不要相信用户的输入。上帝本人是否想要在您的网站上拥有帐户并不重要。
  • 转义密码以确保没有帐户的人可以通过 SQL 注入进行访问。您可以使用 PHP 的 mysql_real_escape_string 函数来完成此操作。
  • 一切就绪后,您可以查询数据库以查看是否返回任何行。

最后,切勿以纯文本形式通过电子邮件向用户发送密码。如果用户忘记了密码,只需允许他们创建一个新密码即可。您可以通过在用户的电子邮件中向用户发送一个链接来完成此操作,这将使他们能够执行此操作。

老实说,您最好的选择可能是完成此任务并用您的代码回发(新问题)。从那里我们可以分析它并从那里获取它。

类似的东西应该满足您的要求。

The simplest thing you could do is hash and apply a salt to your passwords before entering them into the database. "The Wicked Flea" has a pretty good answer in another question here.

Have you thought about grabbing an off the shelf CMS? Most decent CMS's should contain all the functionality you need for a simple charity website. It would also give you a solid solution to your login form issue.

EDIT

As for what language to use. It really isn't very important so long as you are comfortable with it and willing to put time and effort. It shows in your profile that you're looking to learn PHP. Looks like writing a login form in PHP would be a nice starting point. As for a database back end. Again, it doesn't really matter. Just please just do not use MS Access. Most PHP developers (assuming) seem to use MySQL since it's usually what is included with a PHP web host.

About security, hashing and adding a salt to your password is about the easiest thing you can do. You could do something like this:

  • User clicks sign up link
  • Bring up sign up form using SSL
  • Once user clicks the submit button
  • Hash password. Add salt. Store in database. Adding a salt to your hashed password will prevent attacked from using a rainbow table to brute force your passwords. Take a look here for functions that take care of hashing passwords.
  • You could also force users to create a password with specific rules. Such as, requiring all passwords to be greater than 6 characters, at least one number, etc...

Once the user needs to log in, you can do something similar to:

  • Get username and sanitize it. Remember to NEVER trust the users input. It doesn't matter if God himself wants an account on your website.
  • Escape the password to ensure people without an account get access via SQL injection. You can do this using PHP's mysql_real_escape_string function.
  • Once all is in place you can query your database to see if there are any rows returned.

Lastly, never email your user their password in plain text. If the user forgets their password, simply allow them to create a new password. You can do this by sending the user a link in their email which will give them the ability to do so.

Honestly, your best bet is probably to complete this task and post back (new question) on SO with your code. From there we can analyze it and take it from there.

Something along those lines should fulfill your requirements.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文