authx_civicrm_enable - Don't enable `Authorization:` headers if there's plausible...
authorTim Otten <totten@civicrm.org>
Tue, 1 Mar 2022 23:07:19 +0000 (15:07 -0800)
committerTim Otten <totten@civicrm.org>
Tue, 26 Apr 2022 00:48:55 +0000 (17:48 -0700)
commit2a62e03cbe95009ec3b6612c3aaede6ded690587
tree1723a25f4e00276e6be534ad70ca071f93713016
parent4570ea17d7f68328a992a4a1b4502ecefec818f4
authx_civicrm_enable - Don't enable `Authorization:` headers if there's plausible conflict

Some deployments may have two layers of authorization:

(1) A generic/site-wide HTTP basic check (perhaps to prevent search-engines
    from finding the site; perhaps enforced by a reverse proxy)
(2) A Civi or CMS credential (eg session-cookie, ?_authx, or X-Civi-Auth:)

Authx sits in layer 2.  It should enable HTTP `Authorization:` handling
if-and-only-if there is NOT a pre-existing `Authorization:` mechanism.

To test this, I enabled the extension over APIv3 REST -- with/without a superfluous header:

```
curl -X POST -d 'entity=Extension&action=enable&json=%7B%22keys%22%3A%22authx%22%7D&api_key=FIXME_USER_KEY&key=FIXME_SITE_KEY' \
  'http://dmaster.127.0.0.1.nip.io:8001/sites/all/modules/civicrm/extern/rest.php'

curl -X POST -H 'Authorization: Bearer superfluous' -d 'entity=Extension&action=enable&json=%7B%22keys%22%3A%22authx%22%7D&api_key=FIXME_USER_KEY&key=FIXME_SITE_KEY' \
  'http://dmaster.127.0.0.1.nip.io:8001/sites/all/modules/civicrm/extern/rest.php'
```
ext/authx/authx.php
ext/authx/settings/authx.setting.php