Search code examples
hybridauth

'Serialization of 'SimpleXMLElement' is not allowed'


I've changed around the path structure for HybridAuth quite a bit, all of the HybridAuth files are in a login directory.

require_once('login/Auth.php');
$auth = new Hybrid_Auth(self::$settings['auth']);

Where self::$settings['auth'] is this json file

{
  "debug": 1,
  "database": {
    "driver": "mysql",
    "host": "localhost",
    "port": 3306,
    "name": "ws_db",
    "username": "root",
    "password": "",
    "charset": "utf8"
  },
  "auth": {
    "base_url": "http://localhost/login/process",
    "providers": {
      "Twitter": {
        "enabled": true
      },
      "Google": {
        "enabled": true,
        "keys": {
          "id": "",
          "secret": ""
        }
      },
      "Facebook": {
        "enabled": true,
        "keys": {
          "id": "",
          "secret": ""
        },
        "trustForwarded": false
      },
      "Steam": {
        "enabled": true
      }
    },
    "debug_mode": true,
    "debug_file": "auth.txt"
  }
}

I have not yet acquired keys for the providers I intended to use (is that possibly why this is happening?). I tried to login with Steam to test that it was working since it was the only provider that didn't require me to get keys.

$_SESSION['user'] = $auth->authenticate('Steam');

I was correctly redirected to a Steam login page however upon clicking Login I received the above error. Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed' in login\Auth.php:153 Stack trace: #0 login\Auth.php(39): Hybrid_Auth::initialize(Array) #1 index.php(83): Hybrid_Auth->__construct(Array) #2 index.php(6): Site::main() #3 {main} thrown in login\Auth.php on line 153

I thought it possibly had something to do with this line:

Hybrid_Logger::debug( "Hybrid_Auth initialize. dump used config: ", serialize( $config ) );

because that is the only line that I see serializing something but commenting that out didn't seem to work. Line 83 in my index.php is the initialization of Hybrid_Auth.

$auth = new Hybrid_Auth(self::$settings['auth']);

I can't seem to figure out what is going wrong with this though. Since that line of code is run when attempting to login and only causes a problem when returning from the Steam authorization page.

Here is the information that was output into auth.txt, I removed some information.

(
    [message:protected] => Serialization of 'SimpleXMLElement' is not allowed
    [string:Exception:private] => 
    [code:protected] => 0
    [file:protected] => login\Storage.php
    [line:protected] => 73
    [trace:Exception:private] => Array
        (
            [0] => Array
                (
                    [file] => login\Storage.php
                    [line] => 73
                    [function] => serialize
                    [args] => Array
                        (
                            [0] => Hybrid_User Object
                                (
                                    [providerId] => Steam
                                    [timestamp] => 1431707732
                                    [profile] => Hybrid_User_Profile Object
                                        (
                                            [identifier] => ***************
                                            [webSiteURL] => 
                                            [profileURL] => http://steamcommunity.com/id/******/
                                            [photoURL] => 
                                            [displayName] => Renari
                                            [description] => <span>profile information was here</span>
                                            [firstName] => SimpleXMLElement Object
                                                (
                                                    [0] => SimpleXMLElement Object
                                                        (
                                                        )

                                                )

                                            [lastName] => 
                                            [gender] => 
                                            [language] => 
                                            [age] => 
                                            [birthDay] => 
                                            [birthMonth] => 
                                            [birthYear] => 
                                            [email] => 
                                            [emailVerified] => 
                                            [phone] => 
                                            [address] => 
                                            [country] => 
                                            [region] => location information was here
                                            [city] => 
                                            [zip] => 
                                        )

                                )

                        )

                )

            [1] => Array
                (
                    [file] => login\Providers\Steam.php
                    [line] => 37
                    [function] => set
                    [class] => Hybrid_Storage
                    [type] => ->
                    [args] => Array
                        (
                            [0] => hauth_session.Steam.user
                            [1] => Hybrid_User Object
                                (
                                    [providerId] => Steam
                                    [timestamp] => 1431707732
                                    [profile] => Hybrid_User_Profile Object
                                        (
                                            [identifier] => ***************
                                            [webSiteURL] => 
                                            [profileURL] => http://steamcommunity.com/id/******/
                                            [photoURL] => 
                                            [displayName] => ******
                                            [description] => <span>profile information was here</span>
                                            [firstName] => SimpleXMLElement Object
                                                (
                                                    [0] => SimpleXMLElement Object
                                                        (
                                                        )

                                                )

                                            [lastName] => 
                                            [gender] => 
                                            [language] => 
                                            [age] => 
                                            [birthDay] => 
                                            [birthMonth] => 
                                            [birthYear] => 
                                            [email] => 
                                            [emailVerified] => 
                                            [phone] => 
                                            [address] => 
                                            [country] => 
                                            [region] => location information was here
                                            [city] => 
                                            [zip] => 
                                        )

                                )

                        )

                )

            [2] => Array
                (
                    [file] => login\Endpoint.php
                    [line] => 182
                    [function] => loginFinish
                    [class] => Hybrid_Providers_Steam
                    [type] => ->
                    [args] => Array
                        (
                        )

                )

            [3] => Array
                (
                    [file] => login\Endpoint.php
                    [line] => 55
                    [function] => processAuthDone
                    [class] => Hybrid_Endpoint
                    [type] => ->
                    [args] => Array
                        (
                        )

                )

            [4] => Array
                (
                    [file] => login\Endpoint.php
                    [line] => 71
                    [function] => __construct
                    [class] => Hybrid_Endpoint
                    [type] => ->
                    [args] => Array
                        (
                            [0] => 
                        )

                )

            [5] => Array
                (
                    [file] => index.php
                    [line] => 90
                    [function] => process
                    [class] => Hybrid_Endpoint
                    [type] => ::
                    [args] => Array
                        (
                        )

                )

            [6] => Array
                (
                    [file] => index.php
                    [line] => 6
                    [function] => main
                    [class] => Site
                    [type] => ::
                    [args] => Array
                        (
                        )

                )

        )

    [previous:Exception:private] => 
)

Solution

  • This was an issue with the Steam provider and was fixed in a commit you can download the fixed steam provider from the github repo.