0

I'm using Spring Boot in STS to build a simple REST API.

I have some basic security requirements, similar to the ones described in the original post here: RESTful Authentication via Spring

The accepted answer above seems like a valid solution but does not translate to Spring Boot due to the lack of XML configuration.

How would I configure my Spring Boot application in the same manner?

Community
  • 1
  • 1
Nestor Ledon
  • 1,925
  • 2
  • 23
  • 36
  • 1
    You can still use xml with sprnig boot. Simply use a `@ImportResource` to include the xml configuration. Spring Boot already configures Spring Security for you. See http://docs.spring.io/spring-boot/docs/1.1.3.RELEASE/reference/html/boot-features-security.html. How to configure Spring Security with Java based configuration is explained in the Spring Security Reference guide, see http://docs.spring.io/spring-security/site/docs/current/reference/htmlsingle/#jc. – M. Deinum Jul 07 '14 at 06:16
  • Thank you M. Deinum, these look like solid references. – Nestor Ledon Jul 07 '14 at 14:16

1 Answers1

2

You can use the same code as in that post if you want (are you sure that's what you want?) with @Configuration. The HttpSecurity builder has methods addFilter(), addFilterBefore(), addFilterAfter(), so you use those instead of the <custom-filter/> element in XML. Most (if not all) XML elements translate pretty directly into Java config.

Dave Syer
  • 56,583
  • 10
  • 155
  • 143