public static function init_menu()
 {
     add_menu_page(__('Auth0', WPA0_LANG), __('Auth0', WPA0_LANG), 'manage_options', 'wpa0', array('WP_Auth0_Admin', 'render_settings_page'), WP_Auth0::getPluginDirUrl() . 'assets/img/a0icon.png', 81);
     add_submenu_page('wpa0', __('Auth0 Settings', WPA0_LANG), __('Settings', WPA0_LANG), 'manage_options', 'wpa0', array('WP_Auth0_Admin', 'render_settings_page'));
     add_submenu_page('wpa0', __('Auth0 Error Log', WPA0_LANG), __('Error Log', WPA0_LANG), 'manage_options', 'wpa0-errors', array('WP_Auth0_ErrorLog', 'render_settings_page'));
     if (WP_Auth0::isJWTAuthEnabled()) {
         add_submenu_page('wpa0', __('JWT Auth integration', WPA0_LANG), __('JWT Auth integration', WPA0_LANG), 'manage_options', 'wpa0-jwt-auth', array('WP_Auth0_Configure_JWTAUTH', 'render_settings_page'));
     }
 }
 protected static function setupjwt()
 {
     if (WP_Auth0::isJWTAuthEnabled()) {
         JWT_AUTH_Options::set('aud', WP_Auth0_Options::get('client_id'));
         JWT_AUTH_Options::set('secret', WP_Auth0_Options::get('client_secret'));
         JWT_AUTH_Options::set('secret_base64_encoded', true);
         JWT_AUTH_Options::set('override_user_repo', 'WP_Auth0_UsersRepo');
         WP_Auth0_Options::set('jwt_auth_integration', true);
     }
 }
 public static function get_token($domain, $client_id, $client_secret, $grantType = 'client_credentials')
 {
     $endpoint = "https://" . $domain . "/";
     $body = array('client_id' => $client_id, 'client_secret' => $client_secret, 'grant_type' => $grantType);
     $headers = array('content-type' => 'application/x-www-form-urlencoded');
     $response = wp_remote_post($endpoint . 'oauth/token', array('headers' => $headers, 'body' => $body));
     if ($response instanceof WP_Error) {
         WP_Auth0::insertAuth0Error('WP_Auth0_Api_Client::get_token', $response);
         error_log($response->get_error_message());
     }
     return $response;
 }
 public function widget($args, $instance)
 {
     $client_id = WP_Auth0_Options::get('client_id');
     if (trim($client_id) != "") {
         echo $args['before_widget'];
         $settings = WP_Auth0::buildSettings($instance);
         $settings['show_as_modal'] = $this->showAsModal();
         $settings['modal_trigger_name'] = isset($instance['modal_trigger_name']) ? $instance['modal_trigger_name'] : 'Login';
         require_once WPA0_PLUGIN_DIR . 'templates/login-form.php';
         renderAuth0Form(false, $settings);
         echo $args['after_widget'];
     }
 }
 public static function init_admin()
 {
     /* ------------------------- BASIC ------------------------- */
     self::init_option_section('Basic', array(array('id' => 'wpa0_create_account_message', 'name' => '', 'function' => 'create_account_message'), array('id' => 'wpa0_domain', 'name' => 'Domain', 'function' => 'render_domain'), array('id' => 'wpa0_client_id', 'name' => 'Client ID', 'function' => 'render_client_id'), array('id' => 'wpa0_client_secret', 'name' => 'Client Secret', 'function' => 'render_client_secret'), array('id' => 'wpa0_login_enabled', 'name' => 'WordPress login enabled', 'function' => 'render_allow_wordpress_login')));
     /* ------------------------- Appearance ------------------------- */
     self::init_option_section('Appearance', array(array('id' => 'wpa0_form_title', 'name' => 'Form Title', 'function' => 'render_form_title'), array('id' => 'wpa0_social_big_buttons', 'name' => 'Show big social buttons', 'function' => 'render_social_big_buttons'), array('id' => 'wpa0_icon_url', 'name' => 'Icon URL', 'function' => 'render_icon_url'), array('id' => 'wpa0_gravatar', 'name' => 'Enable Gravatar integration', 'function' => 'render_gravatar'), array('id' => 'wpa0_custom_css', 'name' => 'Customize the Login Widget CSS', 'function' => 'render_custom_css')));
     /* ------------------------- ADVANCED ------------------------- */
     $advancedOptions = array(array('id' => 'wpa0_sso', 'name' => 'Single Sign On (SSO)', 'function' => 'render_sso'), array('id' => 'wpa0_dict', 'name' => 'Translation', 'function' => 'render_dict'), array('id' => 'wpa0_username_style', 'name' => 'Username style', 'function' => 'render_username_style'), array('id' => 'wpa0_remember_last_login', 'name' => 'Remember last login', 'function' => 'render_remember_last_login'), array('id' => 'wpa0_default_login_redirection', 'name' => 'Login redirection URL', 'function' => 'render_default_login_redirection'), array('id' => 'wpa0_verified_email', 'name' => 'Requires verified email', 'function' => 'render_verified_email'), array('id' => 'wpa0_allow_signup', 'name' => 'Allow signup', 'function' => 'render_allow_signup'), array('id' => 'wpa0_custom_js', 'name' => 'Customize the Login Widget with custom JS', 'function' => 'render_custom_js'), array('id' => 'wpa0_auth0_implicit_workflow', 'name' => 'Auth0 Implicit flow', 'function' => 'render_auth0_implicit_workflow'), array('id' => 'wpa0_auto_login', 'name' => 'Auto Login (no widget)', 'function' => 'render_auto_login'), array('id' => 'wpa0_auto_login_method', 'name' => 'Auto Login Method', 'function' => 'render_auto_login_method'), array('id' => 'wpa0_ip_range_check', 'name' => 'Enable on IP Ranges', 'function' => 'render_ip_range_check'), array('id' => 'wpa0_ip_ranges', 'name' => 'IP Ranges', 'function' => 'render_ip_ranges'), array('id' => 'wpa0_extra_conf', 'name' => 'Extra settings', 'function' => 'render_extra_conf'), array('id' => 'wpa0_cdn_url', 'name' => 'Widget URL', 'function' => 'render_cdn_url'));
     if (WP_Auth0::isJWTAuthEnabled()) {
         $advancedOptions[] = array('id' => 'wpa0_jwt_auth_integration', 'name' => 'Enable JWT Auth integration', 'function' => 'render_jwt_auth_integration');
     }
     self::init_option_section('Advanced', $advancedOptions);
     register_setting(WP_Auth0_Options::OPTIONS_NAME, WP_Auth0_Options::OPTIONS_NAME, array(__CLASS__, 'input_validator'));
 }
 public static function get_token($domain, $client_id, $client_secret, $grantType = 'client_credentials', $extraBody = null)
 {
     if (!is_array($extraBody)) {
         $body = array();
     } else {
         $body = $extraBody;
     }
     $endpoint = "https://" . $domain . "/";
     $body['client_id'] = $client_id;
     $body['client_secret'] = $client_secret;
     $body['grant_type'] = $grantType;
     $headers = self::get_info_headers();
     $headers['content-type'] = 'application/x-www-form-urlencoded';
     $response = wp_remote_post($endpoint . 'oauth/token', array('headers' => $headers, 'body' => $body));
     if ($response instanceof WP_Error) {
         WP_Auth0::insertAuth0Error('WP_Auth0_Api_Client::get_token', $response);
         error_log($response->get_error_message());
     }
     return $response;
 }
示例#7
0
                if (file_exists($p . $class . $ext)) {
                    require_once $p . $class . $ext;
                    return true;
                }
            }
        }
        return false;
    }
}
if (!function_exists('get_currentauth0userinfo')) {
    function get_currentauth0userinfo()
    {
        global $current_user;
        global $currentauth0_user;
        global $wpdb;
        get_currentuserinfo();
        if ($current_user instanceof WP_User && $current_user->ID > 0) {
            $sql = 'SELECT auth0_obj
                FROM ' . $wpdb->auth0_user . '
                WHERE wp_id = %d';
            $result = $wpdb->get_row($wpdb->prepare($sql, $current_user->ID));
            if (is_null($result) || $result instanceof WP_Error) {
                self::insertAuth0Error('get_currentauth0userinfo', $result);
                return null;
            }
            $currentauth0_user = unserialize($result->auth0_obj);
        }
    }
}
WP_Auth0::init();
示例#8
0
$form_desc = WP_Auth0_Options::get('form_desc');
if (isset($_GET['interim-login']) && $_GET['interim-login'] == 1) {
    $interim_login = true;
} else {
    $interim_login = false;
}
// Get title for login widget
if (empty($title)) {
    $title = "Sign In";
}
$stateObj = array("interim" => $interim_login, "uuid" => uniqid());
if (isset($_GET['redirect_to'])) {
    $stateObj["redirect_to"] = $_GET['redirect_to'];
}
$state = json_encode($stateObj);
$options_obj = WP_Auth0::buildSettings(WP_Auth0_Options::get_options());
$options_obj = array_merge(array("callbackURL" => site_url('/index.php?auth0=1'), "authParams" => array("state" => $state)), $options_obj);
if (isset($specialSettings)) {
    $options_obj = array_merge($options_obj, $specialSettings);
}
if (!$showAsModal) {
    $options_obj['container'] = 'auth0-login-form';
}
if (!$allow_signup) {
    $options_obj['disableSignupAction'] = true;
}
$options = json_encode($options_obj);
if (empty($client_id) || empty($domain)) {
    ?>

    <p><?php 
 public static function init_menu()
 {
     add_menu_page(__('Auth0', WPA0_LANG), __('Auth0', WPA0_LANG), 'manage_options', 'wpa0', array('WP_Auth0_Admin', 'render_settings_page'), WP_Auth0::getPluginDirUrl() . 'assets/img/a0icon.png', 81);
     add_submenu_page('wpa0', __('Auth0 Settings', WPA0_LANG), __('Settings', WPA0_LANG), 'manage_options', 'wpa0', array('WP_Auth0_Admin', 'render_settings_page'));
     add_submenu_page('wpa0', __('Auth0 Error Log', WPA0_LANG), __('Error Log', WPA0_LANG), 'manage_options', 'wpa0-errors', array('WP_Auth0_ErrorLog', 'render_settings_page'));
 }