我是 Spring Boot 的新手,所以请帮助我。我已经让它工作到我能够生成一个Bearer Token未经身份验证的请求的地步。接下来,我想将此令牌与端点一起使用,以便对我的请求进行身份验证 - 这就是我遇到麻烦的地方。我总是收到 401,看起来我的配置有问题。这是我的代码
public class ApplicationUser {
private String username;
private String password;
private String role;
public ApplicationUser(String username, String password, String role) {
this.username = username;
this.password = password;
this.role = role;
}
public String getUsername() {
return username;
}
public String getPassword() {
return password;
}
public String getRole() {
return role;
}
}
JwtConfig 类:
@Component("jwtConfig")
public class JwtConfig {
@Value("${security.jwt.uri:/auth/**}")
private String Uri;
@Value("${security.jwt.header:Authorization}")
private String header;
@Value("${security.jwt.prefix:Bearer }")
private String prefix;
@Value("${security.jwt.expiration:#{24*60*60}}")
private int expiration;
@Value("${security.jwt.secret:JwtSecretKey}")
private String secret;
public String getUri() {
return Uri;
}
public String getHeader() {
return header;
}
public String getPrefix() {
return prefix;
}
public int getExpiration() {
return expiration;
}
public String getSecret() {
return secret;
}
}
烙印99
素胚勾勒不出你
德玛西亚99
相关分类