How can I do an SSO to REST API with Spring security?
<p>I have an application comprised of an NGINX server, front end server and a backend server.</p>

<p>The NGINX and frontend handle the login (some legacy code I have to use for now), and it is done successfully.</p>

<p>I need to do an SSO to the RESTfull API with Spring Security.
The API is running in a Spring-boot application on an embedded tomcat 8 server.</p>

<p>The spring-security version is 4.0.3, the spring-boot version is 1.3.3.</p>

<p>I started with:</p>

<pre><code>@Configuration
@EnableWebSecurity()
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Override
    protected void configure(HttpSecurity http) throws Exception {
        http
                .authorizeRequests()
                .anyRequest().permitAll();
    }
}
</code></pre>

<p>And now I get 401 (unauthorised) from the API, looking at the legacy code and consulting with other developers (I am new to the organisation), I can see that when using an XML configuration they used:</p>

<pre><code>&lt;authentication-manager alias="authenticationManager"/&gt;
</code></pre>

<p>So the authentication manager just passes the requests (and they do the rest of the verifications in filters).</p>

<p>I would like to do something similar, or add the verification of data present in the headers at this stage, but I can't find a clear documentation for this that is not for XML configuration.</p>

<p>I thought this might be equivalent to the XML code used in the legacy system, but it doesn't work:</p>

<pre><code>@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.parentAuthenticationManager(authentication -&gt; {
        authentication.setAuthenticated(true);
        return authentication;
    });
}
</code></pre>

<p>I am looking for a correction to my ideas, or alternative ways to do this.</p>