Score:0

How do I order authentication options correctly in Apache, by location?

cn flag

The order required is:

  1. Basic Auth - IF Authorization is in the header
  2. SAML Auth
  3. For 2 specific locations, no auth

This is what I have, but it does not seem to work correctly

<Location "/">
   AuthType Basic
   AuthBasicProvider ldap
   ...

   <If "-z req('Authorization')">
      AuthType Mellon
      MellonEnable auth
      MellonEndpointPath /mellon/
      ...
   </If>
</Location>

<LocationMatch "^/(notifyCommit|shuttingDown)/">
   AuthType None
   Allow from all
   Satisfy any
   Require all granted
</LocationMatch>

However, any time I try to access either of the two locations where authentication should not be required (notifyCommit or shuttingDown), I get a 401.

What am I doing wrong here? I am under the impression that Location and LocationMatch are merged together, and the order is top-to-bottom. If this is true, it should evaluate "/" first and see that auth is needed, but then find the location match section, and see that auth is not needed for /notifyCommit/ or /shuttingDown/.

I've gone through a few other related questions and tried a bunch of options, but none seemed to work, including moving the location match before the location section, and SetEnvFf Request_URI ....

EDIT

  1. For the two locations where authentication is not required, no username or password should be needed. It is basically anonymous access.
  2. The SAML/Basic auth conditional section seems to be working fine.
ng flag
I'm not sure, but maybe look into the AuthMerging directive!
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.