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.
Let me show you what I've got:
Custom AuthenticationProvider:
@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<?> authentication) {
logger.info("Supports...");
return true;
}
}
WebSecurity config:
@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();
}
}
As you can see I've added loggers into the AuthenticationProvider but not any of them is getting called.
What I've tried:
- adding
@Autowired
toconfigure
where theAuthenticationManagerBuilder
is - adding
@EnableGlobalMethodSecurity(prePostEnabled=true)
to the class - adding custom
AuthenticationProvider
directly toHttpSecurity
How I've tested it:
- debugging via IntelliJ - no results, no breakpoint is getting called.
- running the app and sending a request - also no results, no logs, nothing.
Please guys help me somehow. I'm outta energy. I hate wasting so much time on things that should just work :(