Security configuration without XML with custom filters? - spring

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?

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.

Related

Using 'feign clients' without springboot is possible?

My framework is spring framework. core version is 4.3.16.RELEASE.
Not using springboot. It's one of the legacy project.
And I wanna know what can I use the feign client without springboot.
Is this possible? and where can I found document about that.
thanks for your help :)
Yes, it's possible. You can find the documentation on their Github page.
Feign wasn't integrated with Spring initially. There is another wrapper library called Spring Cloud OpenFeign, and with it, you can use Feign in Spring Boot & Cloud applications more convenient (eg., you can use Spring's #RequestMapping annotation instead of default Feign's #RequestLine).

Integration between Couchdb and Spring

I am new to Spring and Couchdb. I have made a login interface in Spring that authenticates the user using Spring-Security.
Can anybody tell how to add user information at the time of log-in in a Couchdb Database ?
Well, there is no defintion of "spring-mvc annotation" based project.
In this case, someone is trying to differentiate between the usage of annotations and xml-configuration based dependency injection and project configuration.
In case you are not familiar with the old way of using spring-mvc, you might take a look on this example.
If you are planning to use spring-mvc in a new project, i would strongly recommend to use spring and spring-mvc with an annotation based style, as described in the spring reference.

How to use a Spring Boot enabled library inside a old-school spring server

tl/dr (How) Is it possible to use a jar library, that uses Spring Boot for configuration in a non Spring Boot (regular old-school Spring) server.
We have the problem, that we have a Spring server, that is from the pre-Boot times and we want to create a new library for it. We would like to use Spring Boot in the library (i.e. #EnableAutoConfiguration for configuration). To include the library we have put an spring.xml into the library that enables component-scan inside the library. The classes inside the library use #EnableAutoConfiguration and #EnableWebSecurity to enable configuration and security.
If we include now the library into our server and import the XML file from the library into the server's XML file, only parts of the configuration are working. The #RequestMappings in the library are working and the interfaces are available. However Spring security fails to register it's default filter chain, leading to ugly errors, where the regular Spring Boot config should already work with AnonymousAuthorizationFilter, etc.
We debugged, that the FilterRegistrationBean in spring security is never configured when running that way (and is, if we are running as a Spring Boot application).
So is there a common way how to deal with Spring Boot enabled libraries inside old-school Spring servers?
Is placing a single XML to enable component-scan in the library and importing this XML inside the main server's XML the correct way to include Spring Boot libraries (and how would be the best way, if the server would use Spring Boot itself)?
Does anyone know of the issue with a missing Spring Security filter chain?
PS: I know that we can add the required filters manually. However if we would do that, we would anyway get rid of Spring Boot completely in the library, so this question mainly aims for how to do it with Spring Boot. Of course if it is the wrong way to enable Spring Boot inside a library, please also mention that :-)

Spring Boot and contract first Soap WebService

I am currently trying to develop a Soap webservice based on a wsdl I got from an external supplier. The goal is to implement this using Spring Boot. I need to provide the server implementation from the provided wsdl. However I searched all over and tried some different combinations I am stuck on how I can implement the WebService using Spring Boot.
I tried using the example given on http://spring.io/guides/gs/producing-web-service/ but this does not give me the correct result. The interfaces to implement the webservice are nog generated.
Any hints or tips on how contract first Soap webservice can be implemented using Spring Boot?
The issue I see you want to generate java objects from WSDL.
Preferable way is to use cxf-codegen-plugin for that.
Then just use spring-boot as describer in example given in question.
Hope this will help you.

Questions integrating new Groovy template engine with Spring MVC and Spring Boot

As blogged on spring.io both Spring 4.1 and Sprig Boot will integrate the new Groovy template engine (https://spring.io/blog/2014/05/28/using-the-innovative-groovy-template-engine-in-spring-boot, http://spring.io/blog/2014/07/28/spring-framework-4-1-spring-mvc-improvements).
I wonder the following:
Will Spring provide something like it does with the Spring Forms and Spring Security taglib?
If not what would be best to e.g. render form fields and more importantly form errors?
I think without it it will be a step back to develop a traditional Spring MVC webapp.
The template engine suports something like a BaseTemplate (see http://mrhaki.blogspot.nl/2014/08/groovy-goodness-use-custom-template.html) where it would be possible to provide custom methods to the template engine.
Related to this:
You can only provdide a single base template, so it will be difficult to include methods from multiple extension points. E.g. Spring Forms, Spring Security and multiple custom extensions like Fontawesome.
Is it possible to set the base template with Spring Boot?
A simple way to expose a lot of the spring specific attributes csrf etc... is to include spring.groovy.template.expose-request-attributes = true in your application.properties

Resources