diff --git a/plugin/azure_active_directory/index.php b/plugin/azure_active_directory/index.php index 0fb4d78e45..a63dfce7fa 100644 --- a/plugin/azure_active_directory/index.php +++ b/plugin/azure_active_directory/index.php @@ -13,4 +13,8 @@ if ($activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_ENABLE) === 'true' $_template['block_title'] = $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_BLOCK_NAME); $_template['signin_url'] = $activeDirectoryPlugin->getUrl(AzureActiveDirectory::URL_TYPE_AUTHORIZE); + + if ('true' === $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_FORCE_LOGOUT_BUTTON)) { + $_template['signout_url'] = $activeDirectoryPlugin->getUrl(AzureActiveDirectory::URL_TYPE_LOGOUT); + } } diff --git a/plugin/azure_active_directory/install.php b/plugin/azure_active_directory/install.php new file mode 100644 index 0000000000..d1e7fac719 --- /dev/null +++ b/plugin/azure_active_directory/install.php @@ -0,0 +1,8 @@ +install(); diff --git a/plugin/azure_active_directory/lang/english.php b/plugin/azure_active_directory/lang/english.php index c393129da4..77c2d83c09 100644 --- a/plugin/azure_active_directory/lang/english.php +++ b/plugin/azure_active_directory/lang/english.php @@ -14,12 +14,8 @@ $strings['enable'] = 'Enable'; $strings['app_id'] = 'Application ID'; $strings['app_id_help'] = 'Enter the Application Id assinged to your app by the Azure portal, e.g. 580e250c-8f26-49d0-bee8-1c078add1609'; $strings['app_secret'] = 'Application secret'; -$strings['tenant_help'] = 'Enter the name of your B2C directory, e.g. contoso.onmicrosoft.com'; -$strings['signup_policy'] = 'Sign up policy'; -$strings['signup_policy_help'] = 'Enter your sign up policy name, e.g.g b2c_1_sign_up'; -$strings['signin_policy'] = 'Sign in policy'; -$strings['signin_policy_help'] = 'Enter your sign in policy name, e.g. b2c_1_sign_in'; -$strings['signunified_policy'] = 'Unified sign in and sign up policy'; -$strings['signunified_policy_help'] = 'Enter your name of unified sign in and sign up policy, e.g. b2c_1_sign_unified'; +$strings['force_logout'] = 'Force logout button'; +$strings['force_logout_help'] = 'Show a button to force logout session from Azure.'; $strings['block_name'] = 'Block name'; -$strings['SignUpAndSignIn'] = 'Sign up and sign in'; +$strings['OrganisationEmail'] = 'Organisation e-mail'; +$strings['AzureId'] = 'Azure ID (mailNickname)'; diff --git a/plugin/azure_active_directory/src/AzureActiveDirectory.php b/plugin/azure_active_directory/src/AzureActiveDirectory.php index ecba89b168..f2566c1317 100644 --- a/plugin/azure_active_directory/src/AzureActiveDirectory.php +++ b/plugin/azure_active_directory/src/AzureActiveDirectory.php @@ -16,10 +16,14 @@ class AzureActiveDirectory extends Plugin const SETTING_APP_ID = 'app_id'; const SETTING_APP_SECRET = 'app_secret'; const SETTING_BLOCK_NAME = 'block_name'; + const SETTING_FORCE_LOGOUT_BUTTON = 'force_logout'; const URL_TYPE_AUTHORIZE = 'login'; const URL_TYPE_LOGOUT = 'logout'; + const EXTRA_FIELD_ORGANISATION_EMAIL = 'organisationemail'; + const EXTRA_FIELD_AZURE_ID = 'azure_id'; + /** * AzureActiveDirectory constructor. */ @@ -30,6 +34,7 @@ class AzureActiveDirectory extends Plugin self::SETTING_APP_ID => 'text', self::SETTING_APP_SECRET => 'text', self::SETTING_BLOCK_NAME => 'text', + self::SETTING_FORCE_LOGOUT_BUTTON => 'boolean', ]; parent::__construct('2.0', 'Angel Fernando Quiroz Campos', $settings); @@ -88,4 +93,23 @@ class AzureActiveDirectory extends Plugin return api_get_path(WEB_PLUGIN_PATH).$this->get_name().'/src/callback.php'; } + + /** + * Create extra fields for user when installing. + */ + public function install() + { + UserManager::create_extra_field( + self::EXTRA_FIELD_ORGANISATION_EMAIL, + ExtraField::FIELD_TYPE_TEXT, + $this->get_lang('OrganisationEmail'), + '' + ); + UserManager::create_extra_field( + self::EXTRA_FIELD_AZURE_ID, + ExtraField::FIELD_TYPE_TEXT, + $this->get_lang('AzureId'), + '' + ); + } } diff --git a/plugin/azure_active_directory/view/block.tpl b/plugin/azure_active_directory/view/block.tpl index 38ccd1a1d0..0b2c31b485 100644 --- a/plugin/azure_active_directory/view/block.tpl +++ b/plugin/azure_active_directory/view/block.tpl @@ -5,5 +5,9 @@ {% endif %} {{ 'SignIn'|get_lang }} + + {% if azure_active_directory.signout_url is not empty %} + {{ 'Logout'|get_lang }} + {% endif %} {% endif %}