我有一个带有SQL / Web依赖项的Spring Boot项目。我有控制器和模型,但没有配置类。这是一个非常简单的项目,因此我通过检查请求标头中的用户特定令牌来进行简单身份验证。在将密码保存到数据库之前,我想使用BCrypt依赖项对密码进行哈希处理,但是Spring Boot不会让我简单地使用静态函数。
我已将以下三个依赖项添加到我的pom.xml中:
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-config</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-web</artifactId>
</dependency>
并在我的控制器中创建了一个端点,以检查静态hashpw函数的输出。
@GetMapping("/bcrypt/{pw}")
public String crypt(@PathVariable String pw)
{
return BCrypt.hashpw(pw, "xxwv");
}
但是现在我添加了这3个依赖项,它使我一直重定向到从未创建的登录页面。我只想在不使用Spring Boot添加从未要求的随机安全性的情况下使用静态哈希函数。
答案 0 :(得分:0)
在我的Application类的注释中添加以下exclude参数解决了该问题:
@SpringBootApplication(exclude = { SecurityAutoConfiguration.class })