Spring security - Custom AuthenticationProvider not working - Java Config
<p>I'm struggling with the problem from the title for few days already and I'm pretty frustrated. I have no idea what I'm doing wrong and why my implementation isn't working.</p>

<p>Let me show you what I've got:</p>

<p>Custom AuthenticationProvider:</p>

<pre><code>@Component
public class AuthProvider implements AuthenticationProvider {

    private Logger logger = LoggerFactory.getLogger(AuthProvider.class);

    public AuthProvider() {
        logger.info("Building...");
    }

    public Authentication authenticate(Authentication authentication) throws AuthenticationException {
        logger.info("Authenticate...");
        return null;
    }

    public boolean supports(Class&lt;?&gt; authentication) {
        logger.info("Supports...");
        return true;
    }
}
</code></pre>

<p>WebSecurity config:</p>

<pre><code>@Configuration
@EnableWebSecurity
public class WebSecurityConfig extends WebSecurityConfigurerAdapter {

    @Autowired
    private AuthProvider authProvider;

    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        auth.authenticationProvider(authProvider);
    }

    @Override
    public void configure(HttpSecurity http) throws Exception {
        http
            .authorizeRequests().anyRequest().authenticated();
    }
}
</code></pre>

<p>As you can see I've added loggers into the AuthenticationProvider but not any of them is getting called. </p>

<p>What I've tried:</p>

<ul>
<li>adding <code>@Autowired</code> to <code>configure</code> where the <code>AuthenticationManagerBuilder</code> is</li>
<li>adding <code>@EnableGlobalMethodSecurity(prePostEnabled=true)</code> to the class</li>
<li>adding custom <code>AuthenticationProvider</code> directly to <code>HttpSecurity</code></li>
</ul>

<p>How I've tested it:</p>

<ul>
<li>debugging via IntelliJ - no results, no breakpoint is getting called. </li>
<li>running the app and sending a request - also no results, no logs, nothing.</li>
</ul>

<p>Please guys help me somehow. I'm outta energy. I hate wasting so much time on things that should just work :(</p>