When the client performs a synchronization call with the MySQLSync server, we can request it to authenticate.
Enabling Authentication
By default when we create a DBPart, authentication is turned off. We have to select ‘Authentication is REQUIRED‘ in order to enable it.

Built-in username/password Authentication
The default authentication mechanism offered by MySQLSync is through an internal users table (z$m$tusers).
We can fill in users’ details (username and password) and assign groups for the user accounts, by choosing: Authentication source: Built-in users table, then selecting the Configure button. A form will be displayed where we can fill in the user accounts.

Custom authentication source
We can provide a custom authentication source, by providing a Java Plugin in a JAR file, reachable at the web server class path.
The Plugin must implement the com.mysqlsync.plugin.AuthenticatorPlugin interface, which is located in the [Server.zip\AuthSDK\auth-plugin.jar file. The interface provides three methods:
- public String getSchema() – returns a unique schema name, which the client can select in order to use this Authentication source
- public String authenticate(String user, String pass) – returns User ID or null if the user/pass credentials are invalid.
- public String getGroupID(String uid) – optional method for getting a group ID out of a User ID
Sample Plugin Implementation
Here is a very simple implementation, that uses hard coded username/password check:
package com.example;
import com.mysqlsync.plugin.AuthenticatorPlugin;
public class SimpleDummyAuthenticator implements AuthenticatorPlugin {
public String getSchema() {
return "simple";
}
// return User ID for username/password
public String authenticate(String user, String pass) {
if ("user".equals(user) && "user".equals(pass))
return "1";
return null;
}
// since this is optional, we can just return null if we don't have a Group ID
public String getGroupID(String uid) {
return null;
}
}
META-INF folder
The next step of implementing the plugin is to create a folder META-INF/services/ and a text file inside it, with name: com.mysqlsync.plugin.AuthenticatorPlugin . The contents of this text file will be a single line with the full class of our SimpleDummyAuthenticator:
com.example.SimpleDummyAuthenticator
Package as JAR file
The compiled plugin and the META-INF folder must be combined in a JAR file and then we can deploy that JAR file to a location, which is part of the web server class path.
At startup the MySQLSync server app will load the plugin and then we can use it from the clients with the method setAuth(user, pass, schema);