Chapter 17. User Authentication and Proxy Selection

In the document ????'s section ???? → Use cases → Logging in, an overview of the login process is given. This chapter details that process, describing the tables and columns involved during the login process.

The DBMgr plays an important role in the login process, as it determines:

  • Whether the username and password are valid.

  • Which Proxy entity to load for the user.

It is highly recommended to use the MySQL database back-end when implementing user authentication. The XML database differs significantly from the MySQL database in this area. A solution that works with the XML database will most likely not work for the MySQL database, and vice-versa. The following sections assume that the MySQL database back-end is being used.

17.1. The bigworldLogOnMapping Table

DBMgr uses the bigworldLogOnMapping table (for details, see Entity Tables) to check login's validity and which Proxy to load for the user. It contains the following columns:

  • logOnName

    Username used to log in BigWorld. This is the primary key.

  • password

    User's password.

  • typeID

    Type ID of the Proxy entity to create. To map the type ID to its name, bigworldEntityTypes table (for details, see Entity Tables.) is used, which columns are described below:

    • type

      ID of entity type, matched with bigworldLogOnMapping table's typeID column to do entity mapping.

    • recordName

      Name of entity type as specified in <res>/scripts/entities.xml.

      For details on this file, see The entities.xml File.

To determine whether a login is valid and which Proxy entity to load, DBMgr executes the following steps:

  1. Find a row in the bigworldLogOnMapping table where the logOnName column matches the username.

  2. Check that the user's password matches the password of the found row.

  3. Load the Proxy entity identified by typeID and recordName.

For this step to succeed, the Proxy entity must already exist in the database. For information on how to create an entity and write it to the database, see Reading and Writing Entities.

BigWorld currently does not provide an API for manipulating bigworldLogOnMapping, therefore it is usually populated using MySQL tools. For information on how BigWorld under some circumstances automatically populates this table, see Accepting All Users.

17.1.1. The bigworldLogOnMapping Table in the XML Database

The XML database implements the equivalent of the bigworldLogOnMapping table in the section _BigWorldInfo/LogOnMapping. Each row is specified using a separate sub-section, as illustrated below:

<root>
  <_BigWorldInfo>
    <LogOnMapping>
      <item>
        <logOnName>  John      </logOnName>
        <password>   acde1234  </password>
        <type>       Account   </type>
        <entityName> Achilles  </entityName>
      </item>
      <item>
        <logOnName>  Peter     </logOnName>
        <password>   zyxw9876  </password>
        <type>       Avatar    </type>
        <entityName> Hercules  </entityName>
      </item>
    </LogOnMapping>
  </_BigWorldInfo>
...
</root>

bigworldLogOnMapping table in XML

In the example above, two rows are specified. The tags correspond to the table columns as described below:

  • logOnName ‐ Corresponds to column: logOnName

  • password ‐ Corresponds to column: password

  • type ‐ Corresponds to column: typeID

  • entityName ‐ Corresponds to column: recordName

When specifying the type of the entity, the type name is used instead of the type ID used by the MySQL database.

Please note that <res>/scripts/db.xml is only read and written to during startup and shutdown, respectively. Therefore, it is not possible to update the _BigWorldInfo/LogOnMapping section and have the changes take effect while DBMgr is running.

17.2. Accepting All Users

During development, it is often convenient to grant all users access to the server, without having to set up a bigworldLogOnMapping table.

This can be achieved by setting bw.xml file's dbMgr/createUnknown[20] configuration option to true. With this configuration, a default entity is created for the user if there is no row matching the username in bigworldLogOnMapping.

The type of the entity created is controlled by the bw.xml file's dbMgr/entityType option. Additionally, if dbMgr/rememberUnknown is set to true, then the entity created for the unknown user is saved in the database, and an entry is added in bigworldLogOnMapping. This effectively adds a new user into the system, and subsequent logins by the same user will be processed via the normal login process.

17.3. Bypassing bigworldLogOnMapping and Using Account Entity

The login processing implemented by the DBMgr is often insufficient for games that require interaction with an external billing system. For this reason, the source code is provided.

Alternatively, to avoid having to modify DBMgr code, user authentication, and Proxy selection can be delegated to an account entity. An account entity is just another BigWorld entity that is implemented using Python script. The DBMgr can be configured to bypass its usual login processing and pass control over to the account entity.

Firstly, the bigworldLogOnMapping table (for details, see Entity Tables) must be emptied.

Then, the following configuration options must be set:

  • dbMgr/entityTypeA ‐ Required value: Your account entity type

    Reason for required value:

    Type of the entity that will handle the login process.

    For details on how to implement entities, see Physical Entity Structure for Scripting.

  • dbMgr/loadUnknownA ‐ Required value: true

    Reason for required value:

    Since at this stage bigworldLogOnMapping table will be empty, all logins will be considered 'unknown'.

    When this option is set to true, DBMgr tries to find an existing entity of the type specified in dbMgr/entityType with a name that matches the username, and uses that as the Proxy entity. If no entity is found, then the login fails.

    Note

    The name of an entity is a property tagged with the <Identifier> tag. For details, see The Identifier Tag.

  • dbMgr/rememberUnknownA ‐ Required value: false

    Reason for required value:

    To preserve the emptiness of bigworldLogOnMapping.

A ‐ For details, see the document Server Operations Guide's section Software Configuration with bw.xml → DBMgr configuration options.

With the above configuration, whenever a user logs in, an account Proxy entity with a name matching the username will be loaded. If there is no account entity matching the username then the login will fail.

After a successful login:

  • On the client ‐ The account's __init__ method is called.

  • On the BaseApp ‐ The account's onEntitiesEnabled method is called.

There are a couple of approaches to retrieving the user's password:

  • On the BaseApp, if the account entity has a property called password, it is automatically set to the user's login password. And, of course, the account's name property will try to match the username.

  • Since the login password sent by the client using BigWorld.connect method is usually sent in clear text, it may be preferable to use an empty password for normal login processing. Then, after the account entity has been created, the client can send an encrypted password to the Proxy.

It is up to the account entity's implementation to verify the user's password. This is usually done by communicating with a third-party billing system. For details on how to communicate with a non-BigWorld process, see Non-Blocking Socket I/O Using Mercury. If the user's password is invalid, then the Proxy entity can destroy itself to disconnect the client.

If the <dbMgr/createUnknown> [21] configuration option is set to true, then a default account entity will be created for any unknown user that logs in. This can be useful ‐ even on production servers ‐ to implement a recruitment feature. The account's Proxy entity can write itself into the database by calling its writeToDB method, effectively adding a new user to the game. Alternatively, the Proxy entity can destroy itself without writing to the database, effectively forgetting that the login ever took place. However, this configuration will leave the server more susceptible to denial-of-service attacks since anyone can cause account entities to be created on the server.

17.4. Using bigworldLogOnMapping Table with an Account Entity

One of the advantages of using the bigworldLogOnMapping table for processing login is to be able to reject invalid logins early in the process. When using an account entity, the user's password is not verified until after the account entity has been created. This makes the server more susceptible to denial-of-service attacks.

By setting <dbMgr/loadUnknown> to false, and updating the typeID and recordName columns of the bigworldLogOnMapping table to refer to an account entity, both methods can be combined. The password column can also be set to something other than the user's password. For example, a CD key can be used. Then an account entity will only be created if the user has a valid CD key. Once the account entity is created, the user's password can be verified.



[20] For details, see the document Server Operations Guide's section ???? → ????.

[21] For details, see the document ????'s section ???? → ????.