rest - Not able to get csrf token with spring security 3.2.7 -
i using spring security 3.2.7 spring boot 1.2.3. building rest application , implementing spring security java config in csrf on default , know can disable in overridden configure method "http.csrf().disable()". suppose don't want disable it, need csrf token. when hit url
localhost:8080/myproject/url
with post request gives
{ "timestamp": 1431682924618, "status": 403, "error": "forbidden", "message": "expected csrf token not found. has session expired?", "path": "/myproject/user" }
so how can hit same url successful result without disabling csrf.
my securityconfig file is:
@configuration @enablewebsecurity public class securityconfig extends websecurityconfigureradapter { @autowired private datasource datasource; @autowired private customuserdetailsservice customuserdetailsservice; @autowired public void configureglobal(authenticationmanagerbuilder auth) throws exception { // in memory authentication /*auth .inmemoryauthentication() .withuser("user").password("password").roles("user");*/ auth.userdetailsservice(customuserdetailsservice); } @override protected void configure(httpsecurity http) throws exception { // http.csrf().disable() //disable csrf security http .authorizerequests() .antmatchers("/myproject/user/signup").permitall() .antmatchers("/myproject/**").hasrole("admin") .and().httpbasic(); } }
Comments
Post a Comment