Add diagnostic entry point to authenticators

The authenticators should have a similar way to print diagnostic
information as filter and routers do. This allows the authenticators to
print the users in their own format.

In the future, all the diagnostic entry points should be changed so that
they return a structure that contains the information in a standard
form. This information can then be formatted in different ways by other
modules.
This commit is contained in:
Markus Mäkelä
2017-02-04 02:46:48 +02:00
parent a909fd0208
commit c6e1705f8d
16 changed files with 196 additions and 314 deletions

View File

@ -40,27 +40,91 @@ typedef struct
} USERS_STATS;
/**
* The user table, this contains the username and authentication data required
* for the authentication implementation within the gateway.
* A generic user table containing the username and authentication data
*/
typedef struct users
{
HASHTABLE *data; /**< The hashtable containing the actual data */
char *(*usersCustomUserFormat)(void *); /**< Optional username format routine */
USERS_STATS stats; /**< The statistics for the users table */
unsigned char cksum[SHA_DIGEST_LENGTH]; /**< The users' table ckecksum */
} USERS;
extern USERS *users_alloc(); /**< Allocate a users table */
extern void users_free(USERS *); /**< Free a users table */
extern int users_add(USERS *, const char *, const char *); /**< Add a user to the users table */
extern int users_delete(USERS *, const char *); /**< Delete a user from the users table */
extern const char *users_fetch(USERS *, const char *); /**< Fetch the authentication data for a user*/
extern int users_update(USERS *, const char *, const char *); /**< Change the password data for a user in
the users table */
extern int users_default_loadusers(SERV_LISTENER *port); /**< A generic implementation of the
authenticator loadusers entry point */
extern void usersPrint(const USERS *); /**< Print data about the users loaded */
extern void dcb_usersPrint(DCB *, const SERVICE *); /**< Print data about the users loaded */
/**
* Allocate a new users table
*
* @return The users table
*/
USERS *users_alloc();
/**
* Remove the users table
*
* @param users The users table to remove
*/
void users_free(USERS *);
/**
* Add a new user to the user table. The user name must be unique
*
* @param users The users table
* @param user The user name
* @param auth The authentication data
* @return The number of users added to the table
*/
int users_add(USERS *, const char *, const char *);
/**
* Delete a user from the user table.
*
* @param users The users table
* @param user The user name
* @return The number of users deleted from the table
*/
int users_delete(USERS *, const char *);
/**
* Fetch the authentication data for a particular user from the users table
*
* @param users The users table
* @param user The user name
* @return The authentication data or NULL on error
*/
const char *users_fetch(USERS *, const char *);
/**
* Change the password data associated with a user in the users
* table.
*
* @param users The users table
* @param user The user name
* @param auth The new authentication details
* @return Number of users updated
*/
int users_update(USERS *, const char *, const char *);
/**
* @brief Default user loading function
*
* A generic key-value user table is allocated for the service.
*
* @param port Listener configuration
* @return Always AUTH_LOADUSERS_OK
*/
int users_default_loadusers(SERV_LISTENER *port);
/**
* @brief Default authenticator diagnostic function
*
* @param dcb DCB where data is printed
* @param port Port whose data is to be printed
*/
void users_default_diagnostic(DCB *dcb, SERV_LISTENER *port);
/**
* Print details of the users storage mechanism
*
* @param users The users table
*/
void usersPrint(const USERS *);
MXS_END_DECLS