This extension allows the use of JWT tokens signed by an Auth0 tenant for authentication of requests by:
-
Retrieving and add the signing key of a specified Auth0 tenant to the registry used to validate JWTs in core AuthX extension.
-
Subscribes to
civi.authx.checkCredential
symphony event dispatched by the Authx, using it to check thesub
claim in the JWT, replacing it with matching an auth0 id against CMS user ids linked to contact ids.
This gets around two limitations (currently) in the civicrm authentication process:
-
CIVICRM_SIGN_KEYS which only supports the
jwt-hs256
andjwt-hs384
cipher suites, while Auth0 (effectively) usesjwt-hs256
suite. -
The underlying Firebse JWT library uses
openssl_verify()
to verify keys using RS* algorithms, which expects it to be in PEM format in (at least) 3 lines.
The extension is licensed under AGPL-3.0.
-
PHP v7.2+
-
CiviCRM (FIXME: Version number)
-
AuthX core extension enabled. [TODO: Refer to the version with the PR adding in the
civi.authx.checkCredential
event in] -
Drupal CMS with Drupal Auth0 library (This is temporary and will be replaced with use of the openid connect library) [TODO: Maybe this would be better handled as some settings to specify which tables to look up]
Learn more about installing CiviCRM extensions in the CiviCRM Sysadmin Guide.
Sysadmins and developers may download the .zip
file for this extension and
install it with the command-line tool cv.
[TODO: Does this work]
cd <extension-dir>
cv dl civiauth0jwt@https://github.com/australiangreens/civiauth0jwt/archive/main.zip
Sysadmins and developers may clone the Git repo for this extension and install it with the command-line tool cv.
git clone https://github.com/australiangreens/civiauth0jwt.git
cv en civiauth0jwt
- Visit
<siteroot>/civicrm/admin/setting/civiauth0jwt
. - Put the auth0 domain of your tenant, without including the scheme. This could
be an auth0 subdomain (yourtenant.auth0.com) or your own subdomain
(auth.yourdomain.com). Note this will be the same as the
iss
claim in your JWTs tokens, minus the https. - Click save.
- This should fetch the latest key sign key id and store the public key (in pem format) as a civicrm setting.
- You can confirm it worked by revisting the setting page. It the "Current key id" and "Current pem" fields should now be populated.
[TODO: ]
If your Auth0 signing key is rotated, simply visiting the settings page and clicking save will fetch the latest one.
Watch this space