저는 스프링 시큐리티를 처음 접했고 그것을 프로젝트에 추가했습니다. 모든 것이 완벽하게 로그인/로그 아웃하고 여러 화면을 탐색하는 것처럼 보입니다. 내가 ExtJS에 그리드를 시도하고 저장소에 기록을 추가 한 후 상점의 동기() 방법이라고 만 할 때, 내가 가지고 -ExtJS는 스프링 보안이 적용된 SYNC를 저장합니다.
Invalid CSRF Token 'null' was found on the request parameter '_csrf' or header 'X-CSRF-TOKEN'.
내가 내가 함께 _csrf 통과해야한다는 것을 알고있다 요청을하지만이 모든 일을 수행하는 가장 좋은 방법에 대해 알고 싶습니다. 도와주세요.
상점에서 sync() 메소드를 호출하면이 _csrf를 AJAX (작성/업데이트/삭제/읽기)와 함께 자동으로 전달할 수 있습니까?
보안 구성
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private UserService userService;
@Autowired
private BCryptPasswordEncoder encoder;
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userService).passwordEncoder(encoder);
}
@Override
protected void configure(HttpSecurity http) throws Exception {
http.authorizeRequests().antMatchers("/**").access("hasRole('ROLE_ADMIN')").and().formLogin().and().csrf();
}
}
의 ExtJS 코드
tbar : [ '->', {
text : 'Add',
handler : function(btn) {
var grid = btn.up('grid');
var editor = grid.findPlugin('rowediting');
grid.getStore().insert(0, {});
editor.startEdit(0, 0);
}
} ],
bbar : [ '->', {
text : 'Save',
handler : function(btn) {
btn.up('grid').getStore().sync();
}
} ],
감사합니다!
많은 분들께 감사드립니다. 큰 도움 :) 나는 CSRF 토큰을 서버에 전달하기 위해 프록시에서 extraparams 옵션을 사용했습니다. –