Azure plugin: Add option to show logout button - refs BT#9859

pull/2990/head
Angel Fernando Quiroz Campos 6 years ago
parent a7ad5865d4
commit 3c7dda22ca
  1. 4
      plugin/azure_active_directory/index.php
  2. 8
      plugin/azure_active_directory/install.php
  3. 12
      plugin/azure_active_directory/lang/english.php
  4. 24
      plugin/azure_active_directory/src/AzureActiveDirectory.php
  5. 4
      plugin/azure_active_directory/view/block.tpl

@ -13,4 +13,8 @@ if ($activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_ENABLE) === 'true'
$_template['block_title'] = $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_BLOCK_NAME); $_template['block_title'] = $activeDirectoryPlugin->get(AzureActiveDirectory::SETTING_BLOCK_NAME);
$_template['signin_url'] = $activeDirectoryPlugin->getUrl(AzureActiveDirectory::URL_TYPE_AUTHORIZE); $_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);
}
} }

@ -0,0 +1,8 @@
<?php
/* For licensing terms, see /license.txt */
if (!api_is_platform_admin()) {
die('You must have admin permissions to install plugins');
}
AzureActiveDirectory::create()->install();

@ -14,12 +14,8 @@ $strings['enable'] = 'Enable';
$strings['app_id'] = 'Application ID'; $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_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['app_secret'] = 'Application secret';
$strings['tenant_help'] = 'Enter the name of your B2C directory, e.g. contoso.onmicrosoft.com'; $strings['force_logout'] = 'Force logout button';
$strings['signup_policy'] = 'Sign up policy'; $strings['force_logout_help'] = 'Show a button to force logout session from Azure.';
$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['block_name'] = 'Block name'; $strings['block_name'] = 'Block name';
$strings['SignUpAndSignIn'] = 'Sign up and sign in'; $strings['OrganisationEmail'] = 'Organisation e-mail';
$strings['AzureId'] = 'Azure ID (mailNickname)';

@ -16,10 +16,14 @@ class AzureActiveDirectory extends Plugin
const SETTING_APP_ID = 'app_id'; const SETTING_APP_ID = 'app_id';
const SETTING_APP_SECRET = 'app_secret'; const SETTING_APP_SECRET = 'app_secret';
const SETTING_BLOCK_NAME = 'block_name'; const SETTING_BLOCK_NAME = 'block_name';
const SETTING_FORCE_LOGOUT_BUTTON = 'force_logout';
const URL_TYPE_AUTHORIZE = 'login'; const URL_TYPE_AUTHORIZE = 'login';
const URL_TYPE_LOGOUT = 'logout'; const URL_TYPE_LOGOUT = 'logout';
const EXTRA_FIELD_ORGANISATION_EMAIL = 'organisationemail';
const EXTRA_FIELD_AZURE_ID = 'azure_id';
/** /**
* AzureActiveDirectory constructor. * AzureActiveDirectory constructor.
*/ */
@ -30,6 +34,7 @@ class AzureActiveDirectory extends Plugin
self::SETTING_APP_ID => 'text', self::SETTING_APP_ID => 'text',
self::SETTING_APP_SECRET => 'text', self::SETTING_APP_SECRET => 'text',
self::SETTING_BLOCK_NAME => 'text', self::SETTING_BLOCK_NAME => 'text',
self::SETTING_FORCE_LOGOUT_BUTTON => 'boolean',
]; ];
parent::__construct('2.0', 'Angel Fernando Quiroz Campos', $settings); 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'; 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'),
''
);
}
} }

@ -5,5 +5,9 @@
{% endif %} {% endif %}
<a href="{{ azure_active_directory.signin_url }}" class="btn btn-default">{{ 'SignIn'|get_lang }}</a> <a href="{{ azure_active_directory.signin_url }}" class="btn btn-default">{{ 'SignIn'|get_lang }}</a>
{% if azure_active_directory.signout_url is not empty %}
<a href="{{ azure_active_directory.signout_url }}" class="btn btn-danger">{{ 'Logout'|get_lang }}</a>
{% endif %}
</div> </div>
{% endif %} {% endif %}

Loading…
Cancel
Save