Skip to content

Commit

Permalink
Improve Caliper env names
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-gardener committed Feb 19, 2021
1 parent 0f2d20e commit 8d2a56d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions CustomHooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ function ChangeAuthFormFields($requests, $fieldInfo, &$formDescriptor, $action)
}

# if Caliper is setup, use a custom actor with puid from LDAP
if (getenv('CaliperHost') && getenv('CaliperAPIKey')) {
if (getenv('CALIPER_HOST') && getenv('CALIPER_API_KEY')) {
$wgHooks['SetCaliperActorObject'][] = 'SetCaliperActor';

// This is the username MediaWiki will use.
Expand Down Expand Up @@ -65,7 +65,7 @@ function SetCaliperActor(&$actor, &$user) {
return false;
}

$caliperLDAPActorHomepage = rtrim(loadenv('CaliperLDAPActorHomepage', ''), '/');
$caliperLDAPActorHomepage = rtrim(loadenv('CALIPER_LDAP_ACTOR_HOMEPAGE', ''), '/');

$actor = (new Person( $caliperLDAPActorHomepage . "/" . $puid ))
->setName($user->getName())
Expand Down
8 changes: 4 additions & 4 deletions LocalSettings.php
Original file line number Diff line number Diff line change
Expand Up @@ -657,10 +657,10 @@ function loadenv($envName, $default = "") {
}

# setup caliper settings if enabled
if (getenv('MEDIAWIKI_EXTENSIONS') && strpos(getenv('MEDIAWIKI_EXTENSIONS'), 'caliper') !== false && loadenv('CaliperHost') && loadenv('CaliperAPIKey')) {
$wgCaliperHost = loadenv('CaliperHost');
$wgCaliperAPIKey = loadenv('CaliperAPIKey');
$wgCaliperAppBaseUrl = loadenv('CaliperAppBaseUrl', null);
if (getenv('MEDIAWIKI_EXTENSIONS') && strpos(getenv('MEDIAWIKI_EXTENSIONS'), 'caliper') !== false && loadenv('CALIPER_HOST') && loadenv('CALIPER_API_KEY')) {
$wgCaliperHost = loadenv('CALIPER_HOST');
$wgCaliperAPIKey = loadenv('CALIPER_API_KEY');
$wgCaliperAppBaseUrl = loadenv('CALIPER_BASE_URL', null);
}

if (getenv('MEDIAWIKI_EXTENSIONS') && strpos(getenv('MEDIAWIKI_EXTENSIONS'), 'LinkTarget') !== false) {
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,15 @@ Customize the login button by modifying the page `MediaWiki:Pluggableauth-loginb

Customize the login help message by modifying the page `MediaWiki:Userlogin-helplink2` and `MediaWiki:Helplogin-url`. The default is a hyperlink "Help with logging in" that links to mediawiki help page.

Customize the help message on `Preferences` page about email addresses by editing the page `MediaWiki:Prefs-help-email`. The default help messages mentioned email addresses are used for password reset, which is irrelevant if mediawiki is setup with LDAP authentication.
Customize the help message on `Preferences` page about email addresses by editing the page `MediaWiki:Prefs-help-email`. The default help messages mentioned email addresses are used for password reset, which is irrelevant if mediawiki is setup with LDAP authentication.

## Custom Caliper actor data

See the [mediawiki-extensions-caliper](https://github.com/ubc/mediawiki-extensions-caliper/blob/master/caliper/actor.php) repo's `CaliperActor` object for the default logged in and logged out users.

You can customize the Caliper actor by using the `SetCaliperActorObject` hook. This container has uses this hook with the `SetCaliperActor` function inside of `CustomHooks.php`.

By default, the `SetCaliperActor` function will use UBC `puid` for the identifier and `CaliperLDAPActorHomepage` environment variable as the base string so the actor identifier will take the form of `CaliperLDAPActorHomepage/LDAP_PUID` (ex: `https://www.ubc.ca/SOME_PUID`). you can instead remove this function and create your own depending on your institution needs, deployment settings, and/or authorization methods.
By default, the `SetCaliperActor` function will use UBC `puid` for the identifier and `CALIPER_LDAP_ACTOR_HOMEPAGE` environment variable as the base string so the actor identifier will take the form of `CaliperLDAPActorHomepage/LDAP_PUID` (ex: `https://www.ubc.ca/SOME_PUID`). you can instead remove this function and create your own depending on your institution needs, deployment settings, and/or authorization methods.

## Debugging with Containers

Expand Down
8 changes: 4 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ services:
#- GOOGLE_ANALYTICS_METRICS_PATH
#- GOOGLE_ANALYTICS_METRICS_VIEWID
- DEBUG=true
# - CaliperHost=https://caliper.imsglobal.org/caliper/PUT_TEST_BEARER_TOKEN_HERE/message
# - CaliperAPIKey=PUT_TEST_BEARER_TOKEN_HERE
# - CaliperAppBaseUrl=http://localhost:8888/test_url/
# - CaliperLDAPActorHomepage=http://media_wiki_ldap_homepage
# - CALIPER_HOST=https://caliper.imsglobal.org/caliper/PUT_TEST_BEARER_TOKEN_HERE/message
# - CALIPER_API_KEY=PUT_TEST_BEARER_TOKEN_HERE
# - CALIPER_BASE_URL=http://localhost:8888/test_url/
# - CALIPER_LDAP_ACTOR_HOMEPAGE=http://media_wiki_ldap_homepage
job_runner:
<<: *app
command: php /var/www/html/maintenance/runJobs.php --wait
Expand Down

0 comments on commit 8d2a56d

Please sign in to comment.