title: Spring Security not returning UserDetails object, only username
body: <p>I had thought that my authorization implementation was done but when attempting to retrieve the UserDetails object, all I'm getting is the username.  </p>
  
  <p>I'm using oauth with the following particulars.</p>
  
  <p>Configuring the AuthenticationManager:</p>
  
  <pre><code>@Override
  protected void configure(AuthenticationManagerBuilder auth) throws Exception {
  auth.userDetailsService(userDetailsService).passwordEncoder(passwordEncoder());
  }
  </code></pre>
  
  <p>With this done, I can debug into my userDetailsService:</p>
  
  <pre><code>@Service
  public class UserServiceImpl implements UserService, UserDetailsService {
  @Override
      public UserDetails loadUserByUsername(String email) throws UsernameNotFoundException {
          MyUser persistedUser = userRepository.findByEmail(email);
  
          if (persistedUser == null) {
              throw new UsernameNotFoundException(String.format("The email %s doesn't exist", email));
          }
  
          List&lt;GrantedAuthority&gt; authorities = new ArrayList&lt;&gt;();
  
          MyUser inMemoryUser = new MyUser(persistedUser.getEmail(), null, persistedUser.getEnabled(), false,
                  false, false, authorities);
  
          return inMemoryUser;
      }
  }
  </code></pre>
  
  <p>This completes fine and my client gets back the JWT.  But I found the following problem when debugging a later controller method.</p>
  
  <pre><code>@GetMapping
  public @ResponseBody Iterable&lt;Curriculum&gt; getMyCurriculums(@AuthenticationPrincipal MyUser injectedUser) {
      Authentication auth = SecurityContextHolder.getContext().getAuthentication();
      MyUser principle = (MyUser) auth.getPrincipal();
      return curriculumService.findByUser(principle);
  }
  </code></pre>
  
  <p>In this case, injectedUser = null, auth is an OAuth2Authentication, and principle is a String - the username.  It should be MyUser</p>