From 7b617429d39efe2ad13fea8141206f9dedb55986 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Fri, 12 Feb 2021 15:16:50 -0800 Subject: [PATCH] authx - Declare settings for allowed flows and credentials --- ext/authx/Civi/Authx/Meta.php | 44 ++++++++++++++++++ ext/authx/settings/authx.setting.php | 69 ++++++++++++++++++++++++++++ 2 files changed, 113 insertions(+) create mode 100644 ext/authx/Civi/Authx/Meta.php create mode 100644 ext/authx/settings/authx.setting.php diff --git a/ext/authx/Civi/Authx/Meta.php b/ext/authx/Civi/Authx/Meta.php new file mode 100644 index 0000000000..26cf29cc89 --- /dev/null +++ b/ext/authx/Civi/Authx/Meta.php @@ -0,0 +1,44 @@ + E::ts('JSON Web Token'), + 'api_key' => E::ts('API Key'), + 'pass' => E::ts('User Password'), + ]; + } + + /** + * @return array + */ + public static function getUserModes() { + return [ + 'ignore' => E::ts('Ignore user accounts'), + 'optional' => E::ts('Optionally load user accounts'), + 'require' => E::ts('Require user accounts'), + ]; + } + + /** + * @return array + */ + public static function getFlowTypes() { + return [ + 'param' => E::ts('Ephemeral: Paramter'), + 'header' => E::ts('Ephemeral: Common Header'), + 'xheader' => E::ts('Ephemeral: X-Header'), + 'endpoint' => E::ts('Persistent: End-point session'), + 'auto' => E::ts('Persistent: Auto session'), + ]; + } + +} diff --git a/ext/authx/settings/authx.setting.php b/ext/authx/settings/authx.setting.php new file mode 100644 index 0000000000..6aaf3b12b9 --- /dev/null +++ b/ext/authx/settings/authx.setting.php @@ -0,0 +1,69 @@ + 'CiviCRM Preferences', + 'group' => 'authx', + 'is_domain' => 1, + 'is_contact' => 0, + 'add' => '5.36', + ]; + + $s = []; + foreach ($flows as $flow) { + $s["authx_{$flow}_cred"] = $basic + [ + 'name' => "authx_{$flow}_cred", + 'type' => 'Array', + 'quick_form_type' => 'Select', + 'html_type' => 'Select', + 'html_attributes' => [ + 'multiple' => 1, + 'class' => 'crm-select2', + ], + 'default' => ['jwt'], + 'title' => ts('Acceptable credentials (%s)'), + 'help_text' => NULL, + 'pseudoconstant' => [ + 'callback' => ['\Civi\Authx\Meta', 'getCredentialTypes'], + ], + ]; + $s["authx_{$flow}_user"] = $basic + [ + 'name' => "authx_{$flow}_user", + 'type' => 'String', + 'quick_form_type' => 'Select', + 'html_type' => 'Select', + 'html_attributes' => [ + 'class' => 'crm-select2', + ], + 'default' => 'optional', + 'title' => ts('User account requirements (%s)'), + 'help_text' => NULL, + 'pseudoconstant' => [ + 'callback' => ['\Civi\Authx\Meta', 'getUserModes'], + ], + ]; + } + return $s; +} + +/** + * Settings metadata file + */ +return _authx_settings(); -- 2.25.1