/**
  * Object constructor
  *
  * @since 0.2.1
  *
  * @param null|AADSSO
  */
 protected function __construct($aadsso = null)
 {
     // Assign properties
     $this->aadsso = is_a($aadsso, 'AADSSO') ? $aadsso : AADSSO::get_instance();
     $this->settings = AADSSO_Settings::get_instance();
     // Add hooks
     add_action('init', array($this, 'init'));
 }
 protected function __construct()
 {
     AADSSO_Profile::get_instance($this);
     $this->settings = AADSSO_Settings::load_settings();
     // Set the redirect urls
     self::$redirect_uri = wp_login_url();
     self::$logout_redirect_uri = wp_login_url();
     // If plugin is not configured, we shouldn't proceed.
     if (!$this->plugin_is_configured()) {
         return;
     }
     // The authenticate filter
     add_filter('authenticate', array($this, 'authenticate'), 1, 3);
     // Some debugging locations
     // Add the <style> element to the login page
     add_action('login_enqueue_scripts', array($this, 'printLoginCss'));
     // Add the link to the organization's sign-in page
     add_action('login_form', array($this, 'printLoginLink'));
     add_action('login_init', array($this, 'maybeBypassLogin'));
 }
 public function __construct()
 {
     // Ensure jQuery is loaded.
     add_action('admin_enqueue_scripts', array($this, 'maybe_include_jquery'));
     // Add the 'Azure AD' options page.
     add_action('admin_menu', array($this, 'add_options_page'));
     // Register the settings.
     add_action('admin_init', array($this, 'register_settings'));
     // Reset settings if requested to.
     add_action('admin_init', array($this, 'maybe_reset_settings'));
     // Migrate settings if requested to.
     add_action('admin_init', array($this, 'maybe_migrate_settings'));
     // If settings were reset, show confirmation.
     add_action('all_admin_notices', array($this, 'notify_if_reset_successful'));
     // If settings were migrated, show confirmation
     add_action('all_admin_notices', array($this, 'notify_json_migrate_status'));
     // Remove query arguments from the REQUEST_URI (leaves $_GET untouched).  Resolves issue #58
     $_SERVER['REQUEST_URI'] = remove_query_arg('aadsso_reset', $_SERVER['REQUEST_URI']);
     $_SERVER['REQUEST_URI'] = remove_query_arg('aadsso_migrate_from_json_status', $_SERVER['REQUEST_URI']);
     // Load stored configuration values (or defaults).
     $this->settings = get_option('aadsso_settings', AADSSO_Settings::get_defaults());
 }
Esempio n. 4
0
 /**
  * Gets the (only) instance of the plugin.
  *
  * @return self The (only) instance of the class.
  */
 public static function get_instance()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
 /**
  * Generates the URL for logging out of Azure AD. (Does not log out of WordPress.)
  */
 function get_logout_url()
 {
     // logout_redirect_uri is not a required setting, use default value if none is set
     $logout_redirect_uri = $this->settings->logout_redirect_uri;
     if (empty($logout_redirect_uri)) {
         $logout_redirect_uri = AADSSO_Settings::get_defaults('logout_redirect_uri');
     }
     return $this->settings->end_session_endpoint . '?' . http_build_query(array('post_logout_redirect_uri' => $logout_redirect_uri));
 }
 public function aad_settings($setting = '', $default = null)
 {
     static $settings = null;
     $settings = is_null($settings) ? AADSSO_Settings::get_instance()->settings : $settings;
     if ($setting) {
         if (array_key_exists($setting, $settings)) {
             return $settings[$setting];
         }
         switch ($setting) {
             case 'profile_api_endpoint':
                 return 'https://qa.profileapi.services.microsoft.com/profileapi/v1/Profile/id';
             case 'profile_avatar_api_endpoint':
                 return 'https://qa.profileapi.services.microsoft.com/profileapi/internal/v1/avatar';
             case 'create_profile_endpoint':
                 return 'https://social.msdn.microsoft.com/Profile/u/create';
             default:
                 return $default;
         }
     }
     return $settings;
 }
\t\t\t\t<a class="dim" href="%s">Sign out</a>
\t\t\t</p>
EOF;
        printf($html, $this->get_login_url(), htmlentities($this->settings->org_display_name), $this->getLogoutUrl());
    }
}
$settings = AADSSO_Settings::loadSettingsFromJSON(AADSSO_SETTINGS_PATH);
$aadsso = AADSSO::getInstance($settings);
if (!file_exists(AADSSO_SETTINGS_PATH)) {
    function addsso_settings_missing_noticein()
    {
        echo '<div id="message" class="error"><p>' . __('Azure Active Directory Single Sign-on for WordPress requires a Settings.json file ' . ' to be added to the plugin.', 'aad-sso-wordpress') . '</p></div>';
    }
    add_action('all_admin_notices', 'addsso_settings_missing_notice');
} else {
    $settings = AADSSO_Settings::loadSettingsFromJSON(AADSSO_SETTINGS_PATH);
    $aadsso = AADSSO::getInstance($settings);
}
if (!function_exists('com_create_guid')) {
    function com_create_guid()
    {
        mt_srand((double) microtime() * 10000);
        //optional for php 4.2.0 and up.
        $charid = strtoupper(md5(uniqid(rand(), true)));
        $hyphen = chr(45);
        // "-"
        $uuid = chr(123) . substr($charid, 0, 8) . $hyphen . substr($charid, 8, 4) . $hyphen . substr($charid, 12, 4) . $hyphen . substr($charid, 16, 4) . $hyphen . substr($charid, 20, 12) . chr(125);
        // "}"
        return $uuid;
    }
}