我有一个简单的html
登录表单
<form method="post" action="http://www.example.com/login">
<input type="text" name="text_box" />
<input type="password" name="pass_word" />
<input type="submit" name="submit">
</form>
当我提交表单并在控制器中时
public function login(){
$pass_word = $this->input->post('pass_word');
die($pass_word);
}
这里的问题是,如果我输入,它会显示纯密码123456
在控制器中,我得到123456
.
- 这是安全问题吗?
- 任何人都可以通过网络监控工具(例如
wireshark
?
如何避免这种情况?我可以在发送到控制器之前对视图中的密码进行加密吗?
如果您的发布数据(密码等)被拦截,那么它只会以纯文本形式显示。使用 SSL/HTTPS 将为您发送的数据提供加密。我不会依赖客户端 JavaScript 或任何类似的东西来验证/登录用户。由于使用了安全连接,这也可能会让您的用户更有信心。
首先,我只是阅读了有关 SSL 和 HTTPS 的一般信息,以及 SSL 证书 - Wiki、Google 等都是不错的查找地点,那里有大量信息。
对于将 SSL/HTTPS 与 CI 结合使用,我发现这些很有用:
-
http://sajjadhossain.com/2008/10/27/ssl-https-urls-and-codeigniter/
- http://nigel.mcbryde.com.au/2009/03/working-with-ssl-in-codeigniter/
- 如何让 CodeIgniter 使用 SSL 加载特定页面?
特别是强制 ssl 功能奈杰尔的帖子:
在 application/helper 中创建一个名为 ssl_helper.php 的文件
if (!function_exists('force_ssl'))
{
function force_ssl()
{
$CI =& get_instance();
$CI->config->config['base_url'] =
str_replace('http://', 'https://',
$CI->config->config['base_url']);
if ($_SERVER['SERVER_PORT'] != 443)
{
redirect($CI->uri->uri_string());
}
}
}
function remove_ssl()
{
$CI =& get_instance();
$CI->config->config['base_url'] =
str_replace('https://', 'http://',
$CI->config->config['base_url']);
if ($_SERVER['SERVER_PORT'] != 80)
{
redirect($CI->uri->uri_string());
}
}
加载助手,然后在任何控制器的构造函数中
需要 ssl,只需插入:
force_ssl();
在您不希望 ssl 的每个控制器中放置:
if (function_exists('force_ssl')) remove_ssl();
这是一种编程方法,另一种方法是使用 .htaccess (如果您使用的是 Apache)。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)