title: Accessing HttpServletRequest during DaoAuthenticationProvider authenticate in Spring Security
body: <p>I need to access the <code>HttpServletRequest</code> object from within my <code>DaoAuthenticationProvider</code> in Spring security.</p>
  
  <p>The security component extends the <code>DaoAuthenticationProvider</code> and we override the <code>authenticate</code> method to perform some custom authentication / validation. The additional check is required to validate user's ip-address which comes in the request url as a query string parameter (Ex: <code>http://domain.com/context?ip=192.168.0.1</code>).</p>
  
  <p>The current approach I am trying is to make use of <code>RequestContextHolder</code> thread-local and get the http request in my custom <code>DAOAuthenticationProvider</code>.</p>
  
  <p>Some other solutions that I read here and on spring forums seems to suggest to inject <code>AuthenticationDetailsSource</code>, use of <code>custom-filter</code> and other steps which I don't understand due to being new to spring security.</p>
  
  <p>We would have different web applications which use the same security component to perform authentication.</p>
  
  <p>Can someone please point me in a correct direction or help me with any approaches implemented previously ? </p>