我有一个带有 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>
Run Code Online (Sandbox Code Playgroud)
并在我的控制器中创建了一个端点,只是为了检查静态 hashpw 函数的输出。
@GetMapping("/bcrypt/{pw}")
public String crypt(@PathVariable String pw)
{
return BCrypt.hashpw(pw, "xxwv");
}
Run Code Online (Sandbox Code Playgroud)
但是现在我添加了这 3 个依赖项,它不断将我重定向到我从未创建的登录页面。我只想使用静态散列函数,而无需 Spring Boot 添加我从未要求过的随机安全性。