Username and Password not mapping with Authentication in Spring
<p>I'm using Spring 4.3.1.RELEASE version and it's custom Authentication Login application. But I'm facing issue </p>

<p>First take a look on code</p>

<p><strong>CustomAuthenticationProvider.java</strong></p>

<pre><code>@Component
@Qualifier(value = "customAuthenticationProvider")
public class CustomAuthenticationProvider implements AuthenticationProvider{


public Authentication authenticate(Authentication authentication) throws     AuthenticationException {
    String username = authentication.getName();
    String password = (String) authentication.getCredentials();
    User user = new User();
    user.setUsername(username);
    user.setPassword(password);


    Role r = new Role();
    r.setName("ROLE_ADMIN");
    List&lt;Role&gt; roles = new ArrayList&lt;Role&gt;();
    roles.add(r);


    Collection&lt;? extends GrantedAuthority&gt; authorities = roles;
    return new UsernamePasswordAuthenticationToken(user, password, authorities);
}

public boolean supports(Class&lt;?&gt; arg0) {
    return true;
}

}
</code></pre>

<p><strong>SecurityConfiguration.java</strong></p>

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

@Autowired
private CustomAuthenticationProvider customAuthenticationProvider;

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

//.csrf() is optional, enabled by default, if using     WebSecurityConfigurerAdapter constructor
@Override
protected void configure(HttpSecurity http) throws Exception {

    http.authorizeRequests()
            .antMatchers("/admin/**").access("hasRole('ROLE_USER')")
            .and()
            .formLogin()
            .loginPage("/login").failureUrl("/login?error")
            .usernameParameter("username").passwordParameter("password")
            .and()
            .logout().logoutSuccessUrl("/login?logout")
            .and()
            .csrf();
}
}
</code></pre>

<p><strong>login.jsp</strong>
Here is my Login page </p>

<pre><code>  &lt;form name="loginForm" novalidate ng-submit="ctrl.login(user)"&gt;
        &lt;div class="form-group" ng-class="{'has-error': loginForm.username.$invalid}"&gt;
            &lt;input class="form-control" name="username" id="username"  type="text"
                   placeholder="Username" required ng-model="user.username" /&gt;
            &lt;span class="help-block"
                  ng-show="loginForm.username.$error.required"&gt;Required&lt;/span&gt;
        &lt;/div&gt;
        &lt;div class="form-group" ng-class="{'has-error': loginForm.password.$invalid}"&gt;
            &lt;input class="form-control" name="password" id="password" type="password"
                   placeholder="Password" required ng-model="user.password" /&gt;
            &lt;span class="help-block"
                  ng-show="loginForm.password.$error.required"&gt;Required&lt;/span&gt;
        &lt;/div&gt;
        &lt;div class="form-group"&gt;
            &lt;button type="submit" class="btn btn-primary pull-right"
                    value="Login" title="Login" ng-disabled="!loginForm.$valid"&gt;
                &lt;span&gt;Login&lt;/span&gt;
            &lt;/button&gt;
        &lt;/div&gt;
    &lt;/form&gt;
</code></pre>

<p>On authenticate() in CustomAuhtenticationProvider class </p>

<ol>
<li>authentication.getCredentials(); </li>
<li>authentication.getName();</li>
</ol>

<p>both giving empty string , but I need username and password in this.</p>

<p><a href="https://i.stack.imgur.com/hNOnW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hNOnW.png" alt="Here is IntellijIdea Debug screen shot"></a></p>

<p>Here is my AngularJS Service </p>

<p><strong>Service.js</strong></p>

<pre><code>  function loginUser(user) {
    var config = {
        headers: {
            'csrf_token': csrfToken
        }
    }


    var deferred = $q.defer();
    $http.post("/login", user,config)
        .then(
            function (response) {
                deferred.resolve(response.data);
            },
            function(errResponse){
                console.error('Error while creating User');
                deferred.reject(errResponse);
            }
        );
    return deferred.promise;
}
</code></pre>