diff --git a/inc/class-wp-saml-auth.php b/inc/class-wp-saml-auth.php index f49d785..94b884f 100644 --- a/inc/class-wp-saml-auth.php +++ b/inc/class-wp-saml-auth.php @@ -24,6 +24,14 @@ class WP_SAML_Auth { */ private $provider = null; + /** + * Class name to instantiate for SimpleSAML Auth. + * Replaced with namespaced version if available. + * + * @var string + */ + private $simplesamlphp_class = 'SimpleSAML_Auth_Simple'; + /** * Get the controller instance * @@ -84,18 +92,21 @@ public function action_init() { if ( file_exists( $simplesamlphp_path ) ) { require_once $simplesamlphp_path; } - if ( ! class_exists( 'SimpleSAML_Auth_Simple' ) ) { + if ( class_exists( 'SimpleSAML\Auth\Simple' ) ) { + $this->simplesamlphp_class = 'SimpleSAML\Auth\Simple'; + } + if ( ! class_exists( $this->simplesamlphp_class ) ) { add_action( 'admin_notices', function() { if ( current_user_can( 'manage_options' ) ) { // Translators: Links to the WP SAML Auth plugin. - echo '

' . wp_kses_post( sprintf( __( "WP SAML Auth wasn't able to find the SimpleSAML_Auth_Simple class. Please check the simplesamlphp_autoload configuration option, or visit the plugin page for more information.", 'wp-saml-auth' ), 'https://wordpress.org/plugins/wp-saml-auth/' ) ) . '

'; + echo '

' . wp_kses_post( sprintf( __( "WP SAML Auth wasn't able to find the %1\$s class. Please check the simplesamlphp_autoload configuration option, or visit the plugin page for more information.", 'wp-saml-auth' ), $this->simplesamlphp_class, 'https://wordpress.org/plugins/wp-saml-auth/' ) ) . '

'; } } ); return; } - $this->provider = new SimpleSAML_Auth_Simple( self::get_option( 'auth_source' ) ); + $this->provider = new $this->simplesamlphp_class( self::get_option( 'auth_source' ) ); } add_action( 'login_head', array( $this, 'action_login_head' ) ); add_action( 'login_message', array( $this, 'action_login_message' ) ); @@ -240,7 +251,7 @@ public function do_saml_authentication() { $redirect_to = $redirect_to ? : $_SERVER['REQUEST_URI']; $this->provider->login( $redirect_to ); } - } elseif ( is_a( $this->provider, 'SimpleSAML_Auth_Simple' ) ) { + } elseif ( is_a( $this->provider, $this->simplesamlphp_class ) ) { $redirect_to = filter_input( INPUT_GET, 'redirect_to', FILTER_SANITIZE_URL ); if ( $redirect_to ) { $redirect_to = add_query_arg(