我知道这里有很多话题,但是有什么方法可以修改普通的spring安全来处理json对象。休息时的Spring Boot安全
@Configuration
@EnableWebSecurity
@EnableGlobalMethodSecurity(prePostEnabled = true) //za pre i post authorize v servisa
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter
{
//Koi service shte polzvame
@Autowired
private UserService userService;
@Override
protected void configure(HttpSecurity http) throws Exception
{
http.authorizeRequests()
.antMatchers("/", "/user/register", "/css/**", "/js/**").permitAll()
.antMatchers("/user/user").access("hasRole('USER') or hasRole('ADMIN')")
.antMatchers("/user/admin").hasRole("ADMIN")
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/user/login").permitAll()
.usernameParameter("username")
.passwordParameter("password")
.and()
.rememberMe().rememberMeCookieName("RememberMeFromLecture")
.rememberMeParameter("remember")
.key("golqmaTaina")
.and()
.logout().logoutSuccessUrl("/user/login?logout").logoutRequestMatcher(new AntPathRequestMatcher("/signout")).permitAll()
.and()
.exceptionHandling().accessDeniedPage("/user/unauthorized")
.and().csrf().disable();
}
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception
{
auth.userDetailsService(this.userService).passwordEncoder(getBCryptPasswordEncoder());
}
@Bean
public BCryptPasswordEncoder getBCryptPasswordEncoder()
{
return new BCryptPasswordEncoder();
}
}
这是我的配置文件,它的工作原理完全没有休息,但我的问题是,只是想登录页面休息这就是全部的工作。如果它是这样的配置,我的登录自动完成,我甚至不能在我的控制器中设置一个断点。它的工作原理,但我想让它与休息一起工作。
你可以稍微更具体然后请 – Alexander
我刚刚更新了我的答案,请检查并让我知道你是否有任何疑问。 – ManishSingh