mercredi 3 octobre 2018

Apache + OpenID, conditional access for

I am trying to use Apache with OpenID Connect (mod_auth_openidc) to restrict access but on specific paths I want unrestricted access. My httpd.conf contains something like this

    <Location />
        Require valid-user
    </Location>
    <Location /myPath>
        Require all granted
    </Location>

and /myPath indeed has unrestricted access, i.e. unauthorized users get access.

Now I try to add some conditional restrictions using the "If" directives but keep /myPath still unrestricted, e.g.

    <Location />
        <If someBoolean>
            Require valid-user
        </If>
    </Location>
    <Location /myPath>
        Require all granted
    </Location>

In this case I only get the unrestricted access to /myPath if someBoolean is "false". If it is "true" a valid user is needed to access /myPath, which is not what i want. The default path "/" works just fine, i.e. it requires a valid user if and only if someBoolean is "true".

Now I tried further testing: when I add an "Else" directive, e.g.

    <If someBoolean>
        Require valid-user
    </If>
    <Else>
        Require valid-user
    </Else>

which in my understanding should be equivalent to just using

    Require valid-user

I never get unrestricted access to /myPath.

How can I get the behavior I want?

Aucun commentaire:

Enregistrer un commentaire