'Ldap JWT loadUserByUsername

Hello I'm trying to modifiy this example for LDAP authentification https://www.bezkoder.com/spring-boot-refresh-token-jwt/

https://github.com/bezkoder/spring-boot-refresh-token-jwt

I managed to hit the ldap by modifying my security config like that

@Override
    public void configure(AuthenticationManagerBuilder authenticationManagerBuilder) throws Exception {
        authenticationManagerBuilder.authenticationProvider(activeDirectoryLdapAuthenticationProvider());
    }

    @Bean
    public AuthenticationManager authenticationManager() {
        return new ProviderManager(Arrays.asList(activeDirectoryLdapAuthenticationProvider()));
    }

    @Bean
    public AuthenticationProvider activeDirectoryLdapAuthenticationProvider() {
        ActiveDirectoryLdapAuthenticationProvider provider = new ActiveDirectoryLdapAuthenticationProvider(
                "eu.domain", "ldap://eu.domain:389");
        provider.setSearchFilter("(&(objectClass=user)(sAMAccountName={1}))");
        provider.setUserDetailsContextMapper(userDetailsContextMapper());
        provider.setConvertSubErrorCodesToExceptions(true);
        provider.setUseAuthenticationRequestCredentials(true);
        return provider;
    }

    @Bean
    public UserDetailsContextMapper userDetailsContextMapper() {
        return new LdapUserDetailsMapper();
    }

I replaced occurence of UserDetails with LdapUserDetailsImpl

I don't know how to replace userDetailsService.loadUserByUsername in AuthTokenFilter



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source