title: SecurityContextHolder.getContext().getAuthentication() always return 'anonymousUser'
body: <p>I created Spring boot application with the following configuration:</p>
  
  <ul>
  <li>Spring boot 2.1.0.RELEASE </li>
  <li>OpenJdk 11</li>
  </ul>
  
  <p>I have an <code>AuditConfiguration</code> class in my project that looks like:</p>
  
  <pre><code>@Configuration
  @EnableJpaAuditing(auditorAwareRef = "auditorProvider")
  public class AuditConfiguration {
  
      @Bean
      public AuditorAware&lt;String&gt; auditorProvider() {
          return new AuditorAwareImpl();
      }
  
      class AuditorAwareImpl implements AuditorAware&lt;String&gt; {
          @Override
          public Optional&lt;String&gt; getCurrentAuditor() {
              Principal principal = 
              SecurityContextHolder.getContext().getAuthentication();
              return Optional.of(principal.getName());
          }
      }
  }
  </code></pre>
  
  <p>and <code>SecurityContextHolder.getContext().getAuthentication()</code> always returns <code>anonymousUser</code>.</p>
  
  <p>However, the following code returns the correct user name.</p>
  
  <pre><code>@RestController
  @RequestMapping("/history")
  public class HistoryEndpoint {
  
      @RequestMapping(value = "/username", method = RequestMethod.GET)
      @ResponseBody
      public String currentUserName(Principal principal) {
          return principal.getName();
      }
  }
  </code></pre>
  
  <p>I need your help for resolving this issue. </p>