是否有必要使用Spring Security和ldap加密或散列密码?

时间:2019-05-09 18:51:51

标签: spring spring-security hash ldap

我有一个用户登录的前端。它向具有Spring安全性的后端发出请求,并在LDAP中搜索用户。

这是我的ajax前端请求的简单代码:

function login() {

$.ajax({
    url : 'http://localhost:8080/log',
    type : 'POST',
    contentType : 'application/json',
    data : JSON.stringify({
        "user" : $("#loginUser").val(),
        "password" : $("#loginPass").val()
    }),
    success : function(jqXhr, textStatus, data) {



        localStorage.setItem("user",$("#loginUser").val());
        window.open("../dashboard/home.html", "_self");

        console.log(data);
    },
    error : function(jqXhr, textStatus, errorThrown) {
        console.log(errorThrown);
    }
});

}

我需要知道是否有必要通过哈希或加密来增加一些安全性,因为我是以某种方式将普通密码发送到后端以及正在获取LDAP信息的服务器中。

提前谢谢。

1 个答案:

答案 0 :(得分:1)

如果要在POST请求的正文中发送用户名和密码,请使用https(基于TLS的HTTP)。您可能需要配置服务器来进行设置。这样可以确保没有其他人可以解密您的请求的内容。

当请求到达您的Spring Web应用程序时,用户名和密码将为“纯文本”,然后您可以使用它通过LDAP服务器进行身份验证。您可以使用基于LDAP的LDAP与服务器建立安全连接。如果您使用的是Spring Security,请查看spring-ldap文档,以概述Spring如何抽象LDAP连接的某些元素,以及Spring Security参考,以了解如何配置Spring Security框架来通过访问LDAP服务器无缝验证用户身份。