peterp
peterp

Reputation: 3121

How to apply a tomcat security role for all URLs but one?

My administrative web application is secured using basic-auth:

<security-constraint>
  <web-resource-collection>
    <web-resource-name>myApp</web-resource-name>
    <description>
      Security constraint for
      Admin resources
    </description>
    <url-pattern>/*</url-pattern>
    <http-method>POST</http-method>
    <http-method>GET</http-method>
  </web-resource-collection>
  <auth-constraint>
    <description>
      constraint
    </description>
    <role-name>myrolename</role-name>
  </auth-constraint>
  <user-data-constraint>
    <description>SSL not required</description>
    <transport-guarantee>NONE</transport-guarantee>
  </user-data-constraint>
</security-constraint>
<login-config>
  <auth-method>BASIC</auth-method>
  <realm-name>Admin Login</realm-name>
</login-config>

However, I need to establish an exclusion for a single URL (say /check/, used by an automated service checking whether the web application is still up in regular intervals.

Unfortunately I cannot activate basic authentication for this service.

How I can achieve this?

Thanks a lot.

Upvotes: 7

Views: 4458

Answers (1)

peterp
peterp

Reputation: 3121

Adding another constraint before with <transport-guarantee>NONE</transport-guarantee> did the trick

<security-constraint>
    <web-resource-collection>
        <web-resource-name>Status page, accessed internally by application</web-resource-name>
        <url-pattern>/status/</url-pattern>
    </web-resource-collection>
    <user-data-constraint>
        <transport-guarantee>NONE</transport-guarantee>
    </user-data-constraint>
</security-constraint>

Upvotes: 7

Related Questions