Spring boot spring引导授权和身份验证是如何工作的

Spring boot spring引导授权和身份验证是如何工作的,spring-boot,Spring Boot,我从我的同事那里接管了我目前的项目。他用的是弹簧靴。现在我想知道登录和角色是如何工作的。我所能看到的就是这个 @Configuration public class WebSecurityConfig extends WebSecurityConfigurerAdapter { @Autowired Environment env; @Override public void configure(HttpSecurity http) throws Except

我从我的同事那里接管了我目前的项目。他用的是弹簧靴。现在我想知道登录和角色是如何工作的。我所能看到的就是这个

@Configuration
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    Environment env;

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http.authorizeRequests()
                .antMatchers("/api/tester/**").hasAnyRole("TESTER", "AUTHOR", "ADMIN")
                .antMatchers("/api/author/**").hasAnyRole("AUTHOR", "ADMIN")
                .antMatchers("/api/admin/**").hasRole("ADMIN")
                .anyRequest().fullyAuthenticated()
                .and().
                formLogin();
    }

在数据库中有一个带有列authority的authorities表。看来Spring boot知道这一点,并去了那里。我还找到了login.html。看起来Spring Boot也会自动使用它,并提供适当的属性对象${param}。我也找不到控制器。登录的URL只是/login。若您并没有使用框架,那个么在每个页面上,您都需要检查用户当前是否已登录并具有适当的角色。所以在用户表中有一列loggedIn,若为loggedIn,则将其设置为true。我想是吧

你看到UserDetailService实现了吗?没有。但是我不知道你对UserDetailService的意思。