Я применяю простую пружинную защиту при загрузке, до сегодняшнего дня она работала, но в настоящее время она не работает.
Это мой класс конфигурации безопасности, и в настоящее время яне используется шифрование пароля.
@Configuration
@EnableWebSecurity
public class GameSecurityConfiguration extends WebSecurityConfigurerAdapter {
@Autowired
DataSource dataSource;
/*private final String USERS_QUERY = "select email, password from userregistrationmaster where email=?";
private final String ROLES_QUERY = "select u.email, ur.role from userregistrationmaster u inner join authoritiesmaster ur on (u.email = ur.authemail) where u.email=?";*/
/*@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication()
.usersByUsernameQuery(USERS_QUERY)
.authoritiesByUsernameQuery(ROLES_QUERY)
.dataSource(dataSource);
}*/
// Enable jdbc authentication
@Autowired
public void configAuthentication(AuthenticationManagerBuilder auth) throws Exception {
auth.jdbcAuthentication().dataSource(dataSource)
.usersByUsernameQuery("select email,password, enable from userregistrationmaster where email=?")
.authoritiesByUsernameQuery("select u.email, ur.role from userregistrationmaster u inner join authoritiesmaster ur on (u.email = ur.authemail) where u.email=?");
}
@Bean
public JdbcUserDetailsManager jdbcUserDetailsManager() throws Exception {
JdbcUserDetailsManager jdbcUserDetailsManager = new JdbcUserDetailsManager();
jdbcUserDetailsManager.setDataSource(dataSource);
return jdbcUserDetailsManager;
}
@SuppressWarnings("deprecation")
@Bean
public static NoOpPasswordEncoder passwordEncoder() {
return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
}
@Override
public void configure(WebSecurity web) throws Exception {
web.ignoring().antMatchers("/resources/**");
web.ignoring().antMatchers("/css/**");
web.ignoring().antMatchers("/js/**");
}
String[] resources = new String[]{
"/css/**","/fonts/**","/img/**","/images/**","/js/**","/scss/**","/vendors/**","/jsmaster/**","/SendContactEmail/**"
};
String[] lessionChapters = new String[] {
"/chapter3","/chapter4","/chapter5","/chapter6","/chapter7","/chapter8"
};
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/", "/login", "/contact", "/about-us","/lessonplan", "/chapter2", "/mobile-apps", "/website", "/game", "/products", "/registration", "/generateOpt", "/userRegistration", "/userLogin", "/forgotpassword").permitAll()
.antMatchers("/resources/**").permitAll()
.antMatchers(resources).permitAll()
.antMatchers("/game").hasAnyRole("USER","ADMIN")
.antMatchers(lessionChapters).hasAnyRole("USER","ADMIN")
.anyRequest().authenticated()
.and()
.formLogin()
.loginPage("/login")
.failureUrl("/login?error=true")
.and().logout().permitAll();
http.csrf().disable();
}
Это не показывает никакой ошибки, но я создал одного пользователя с USER_ROLE и пытаюсь войти в систему с этим именем пользователя и паролем, он отображает страницу ошибки.
Заранее спасибо за помощь в решении этой моей проблемы.