title: Spring Security - How to access v2 API using basic HTTP authentication in Hybris?
body: <p>I want to access <code>v2</code> API using basic authentication(username/password), I have done all below-mentioned changes. But when I hit the web service URL, I'm getting a popup for providing username/password which is not taking(validating) my username/password. I'm sure I have entered correct username &amp; password.</p>
  
  <p><strong>web.xml:</strong></p>
  
  <pre><code>&lt;security-role&gt;
  &lt;description&gt;
  The role that is required to access the application
  &lt;/description&gt;
  &lt;role-name&gt;admin&lt;/role-name&gt;
  &lt;/security-role&gt;
  &lt;security-constraint&gt;
  &lt;web-resource-collection&gt;
  &lt;web-resource-name&gt;RestrictedWebResource&lt;/web-resource-name&gt;
  &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/web-resource-collection&gt;
  &lt;auth-constraint&gt;
  &lt;role-name&gt;admin&lt;/role-name&gt;
  &lt;/auth-constraint&gt;
  &lt;user-data-constraint&gt;
  &lt;!-- transport-guarantee can be CONFIDENTIAL, INTEGRAL, or NONE --&gt;
  &lt;transport-guarantee&gt;NONE&lt;/transport-guarantee&gt;
  &lt;/user-data-constraint&gt;
  &lt;/security-constraint&gt;
  &lt;login-config&gt;
  &lt;auth-method&gt;BASIC&lt;/auth-method&gt;
  &lt;/login-config&gt;
  </code></pre>
  
  <p><strong>security-v2-spring.xml:</strong></p>
  
  <pre><code>&lt;security:http auto-config="true"  use-expressions="true"&gt;      &lt;security:intercept-url pattern="/rest/*" access="admin" /&gt;
  &lt;security:http-basic /&gt;
  &lt;/security:http&gt;
  &lt;security:authentication-manager&gt;
  &lt;security:authentication-provider&gt;
  &lt;security:user-service&gt;
  &lt;security:user name="ash" password="ash" authorities="admin" /&gt;
  &lt;/security:user-service&gt;
  &lt;/security:authentication-provider&gt;
  &lt;/security:authentication-manager&gt;
  </code></pre>
  
  <p><strong>tomcat-users.xml:</strong></p>
  
  <pre><code>&lt;?xml version='1.0' encoding='utf-8'?&gt;
  &lt;tomcat-users&gt;
  &lt;role rolename="manager"/&gt;
  &lt;role rolename="admin"/&gt;
  &lt;user username="ash" password="ash" roles="admin,manager"/&gt;
  &lt;/tomcat-users&gt;
  </code></pre>
  
  <p><strong>config/local.properties:</strong></p>
  
  <pre><code>hybris.security.http.basic.auth.enable=true
  hybris.security.http.basic.auth.username=ash
  hybris.security.http.basic.auth.password=ash
  </code></pre>
  
  <p>tomcat-users.xml location is correctly configured in server.xml also</p>
  
  <pre><code>&lt;Resource name="UserDatabase" auth="Container"
  type="org.apache.catalina.UserDatabase"
  description="User database that can be updated and saved"
  factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
  pathname="conf/tomcat-users.xml" /&gt;
  </code></pre>
  
  <p>The endpoint URL which I try to access is </p>
  
  <pre><code>https://localhost:9002/rest/v2/**/**/**
  </code></pre>
  
  <p>Usual admin console admin/nimda also doesn't work. I'm breaking my head in this for more than a week now. Any help will be great. Thanks in advance.</p>