spring - Disable csrf using Java configuration -


good day,

i trying learn spring. doing guide: http://spring.io/guides/gs/consuming-rest/

i have followed instructions, however, when try run application, 403 forbidden displayed.

i searched net , found out due csrf protection. , so, proceeded search net how disable csrf. here java configuration:

@enablewebsecurity public class websecurityconfig extends websecurityconfigureradapter {     @override     protected void configure(httpsecurity http) throws exception {         http             .csrf().disable();     } } 

my question is, how use configuration? specifically, @ part of code should insert it?

here other 2 classes stated in tutorial. of them belong same package (hello).

@jsonignoreproperties(ignoreunknown = true) public class page {     private string name;     private string about;     private string phone;     private string website;      public string getname() {         return name;     }      public string getabout() {         return about;     }      public string getphone() {         return phone;     }      public string getwebsite() {         return website;     } }  public class application {      public static void main(string[] args) {         resttemplate resttemplate = new resttemplate();         page page = resttemplate.getforobject("http://graph.facebook.com/pivotalsoftware", page.class);         system.out.println("name:       " + page.getname());         system.out.println("about:      " + page.getabout());         system.out.println("phone:      " + page.getphone());         system.out.println("website:    " + page.getwebsite());     }  } 

add @configuration on websecurityconfig class , automatically scanned when launch spring application. don't need write code.

here code @configuration

@configuration @enablewebsecurity public class websecurityconfig extends websecurityconfigureradapter {     @override     protected void configure(httpsecurity http) throws exception {         http             .csrf().disable();     } } 

Comments

Popular posts from this blog

jquery - How do you format the date used in the popover widget title of FullCalendar? -

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -