Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

authx - Accept API keys by default #20081

Merged
merged 1 commit into from
May 17, 2021

Conversation

totten
Copy link
Member

@totten totten commented Apr 16, 2021

Overview

This slightly relaxes the default settings so that it is easier to use authx as a replacement for extern/rest.php (which
uses the api_key for authentication).

Before

extern/rest.php accepts api_keys.

authx can accept api_keys, but you have to change some settings to allow it.

After

Both extern/rest.php and authx accept api_keys by default.

Comments

The defaults in authx were designed to be a bit paranoid. The basic goal -- don't let anyone open up access accidentally. However, the current protections are a bit of overkill. Suppose you're setting up an API key for use with civicrm/ajax/*. Here are the sysadmin tasks:

  1. Create an API key (civicrm_contact.api_key). (Doing this requires edit api keys or edit own api keys.)
  2. Enable authx (It's inert otherwise.)
  3. Grant the user permission authenticate via api key, or convey the SITE_KEY to the user, or disable all authx_guards
  4. Update the setting authx_header_cred or authx_xheader_cred or authx_param_cred to allow api_key

Notably, the default in #4 was chosen during earlier drafting... before authx_guards existed. But now we have the guards, and we have even more steps to go through.

This change relaxes the defaults so that step #4 is not necessary. This arrangement is still fairly paranoid (ie we still have 1+2+3). Compared to extern/rest.php, there's still an extra opt-in hoop.

Overview
--------

This slightly relaxes the default settings so that it is easier to use `authx` as a replacement for `extern/rest.php` (which
uses the `api_key` for authentication).

Before
------

`extern/rest.php` accepts `api_key`s.

`authx` can accept `api_key`s, but you have to change some settings to allow it.

After
-----

Both `extern/rest.php` and `authx` accept `api_key`s by default.

Comments
-----------------

The defaults in authx were designed to be a bit paranoid.  The basic goal -- don't let anyone open up access
accidentally.  However, the current protections are a bit of overkill.  Suppose you've created an `api_key` (sufficient
for `extern/rest.php`) and you want to switch to using `civicrm/ajax/*`. Here are the sysadmin tasks:

1. Enable `authx` (*It's inert otherwise.*)
2. Grant the user permission `authenticate via api key`, or convey the `SITE_KEY` to the user, or disable all `authx_guards`
3. Update the setting `authx_header_cred` or `authx_xheader_cred` or `authx_param_cred` to allow `api_key`

Notably, when this default was first chosen during drafting, the `authx_guards` (step 2) didn't exist. But now they do, and we have even more steps to go through.

This change relaxes the defaults so that step `civicrm#3` is not necessary. This arrangement is still fairly paranoid (ie we still have 1+2 -- compared
to `extern/rest.php`, there's still an extra opt-in hoop).
@civibot
Copy link

civibot bot commented Apr 16, 2021

(Standard links)

@civibot civibot bot added the master label Apr 16, 2021
@seamuslee001
Copy link
Contributor

So I think this is ok in my book but would appreciate @MikeyMJCO 's view on this matter as well

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 I'm inclined to merge as I think @MikeyMJCO has had enough time to comment if he wants to

@homotechsual
Copy link
Contributor

This is good with me :-)

@eileenmcnaughton eileenmcnaughton merged commit 201062b into civicrm:master May 17, 2021
@eileenmcnaughton
Copy link
Contributor

thanks for confirming @MikeyMJCO

@totten totten deleted the master-authx-defaults branch June 17, 2021 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants