我无法以用户

时间:2018-12-11 17:41:16

标签: java spring-boot

当我以admin身份登录时,我从github Link here克隆了这个spring-boot项目并尝试运行它。一切正常。
enter image description here
但是当我登录时以用户身份显示此页面enter image description here
SecurityConfig.java

@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {

    private static final String HBS_ADMIN = "/hbs/**";
    private static final String HBS_USER = "/hbs/*";
    private static final String ADMIN = "ADMIN";
    private static final String USER = "USER";

    @Override
    public void configure(HttpSecurity httpSecurity) throws Exception{
        httpSecurity
                .authorizeRequests()
                .antMatchers(HBS_ADMIN).hasRole(ADMIN)
                .antMatchers(HBS_USER).hasRole(USER)
            .and()
                .formLogin();
    }

    @Autowired
    public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception{
        auth.inMemoryAuthentication()
                .withUser("admin").password("password").roles(ADMIN)
                .and()
                .withUser("user").password("password").roles(USER);
    }
}

请帮助我,谢谢。

0 个答案:

没有答案
相关问题