190 Commits

Author SHA1 Message Date
Markus Mäkelä
c6e1705f8d 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.
2017-02-07 10:03:58 +02:00
Markus Mäkelä
a909fd0208 Fix injection of service user
The parameters that were given to the user creation function were in the
wrong order.
2017-02-07 10:03:58 +02:00
Markus Mäkelä
62fdd68ac0 Make sure user cache directory exists
The cache directory needs to be created by the authenticator itself.
2017-02-07 10:03:58 +02:00
Markus Mäkelä
70061e6323 Return correct value for failed db authentication
The unknown database error was never triggered as all authentication
errors returned MXS_AUTH_FAILED.
2017-02-07 10:03:58 +02:00
Markus Mäkelä
11c3e6ac91 Don't users with a pre-4.1 password
The old error message and behavior was lost with the new implementation.
2017-02-07 10:03:58 +02:00
Markus Mäkelä
9a80e1cd5b Reorder SQL statements when persisting users
The statements are now executed in a more controlled order and a failure
of one will skip the others. The transaction is also rolled back if it
fails.
2017-02-07 10:03:58 +02:00
Markus Mäkelä
7ad7536b57 Fix enable_root_user
The option was inverted.
2017-02-07 10:03:58 +02:00
Markus Mäkelä
7dce744e0b Remove unused code from MySQLAuth
Removed the old implementation of MySQL authentication. The user printing
functionality still expects a hashtable which should be fixed.
2017-02-07 10:03:58 +02:00
Markus Mäkelä
4d5d988bf0 Exact hostnames grants take precedence over wildcard grants
MariaDB and others match grants first by exact hostname/IP and then by
wildcard. If there are no exact matches, the wildcard grant should be
picked. This can be tested by having different passwords for localhost and
remote address.

The SQLite based authentication should first check for an exact match and
then only after that should it try to match the hostname to a wildcard
grant.
2017-02-07 10:03:57 +02:00
Markus Mäkelä
2b59d5031e Fix memory leak in dbusers.c
The MySQL connection was created twice.
2017-02-07 10:03:57 +02:00
Markus Mäkelä
fe1a49f4e9 Use new authentication for reauthentication
This fixes the reauthentication of users that was missing from the new
implementation. Now COM_CHANGE_USER should work properly.
2017-02-07 10:03:57 +02:00
Markus Mäkelä
acdde499ed Replace get_users implementation with new version
The get_users function now combines the functionality of the old get_users
and get_all_users. This removes large parts of similar code.

Removed the listener resources as MySQLAuth was the only one that used it.
2017-02-07 10:03:57 +02:00
Markus Mäkelä
3d2fc2ccb2 Store SQLite tables on disk
The SQLite database users are cached on disk. This allows the binlogrouter
to authenticate users without a connection to the master server.
2017-02-07 10:03:57 +02:00
Markus Mäkelä
54d8eb9595 Store databases in the SQLite database
The databases are now also stored in the sqlite database. This allows the
`resource` member of the USERS struct to be removed in the future.
2017-02-07 10:03:57 +02:00
Markus Mäkelä
2b4ff82999 Use SQLite3 based authentication
The user data is now stored inside a SQLite3 database. By storing the data
inside a database, we remove the restriction that the previous hashtable
based implementation had.
2017-02-07 10:03:57 +02:00
Markus Mäkelä
ce5e429ad3 Move reauthentication to authenticators
Currently the only situation where a user needs to be authenticated after
the initial authentication is when a COM_CHANGE_USER is being
executed. This was previously handled by directly calling a function in
the MySQLAuth authenticator.

The new entry in the API of the authenticators is very specific to MySQL
and should be reviewed once other protocols are added.
2017-02-07 10:03:57 +02:00
Markus Mäkelä
a5a579ffce Rename BUILD_AVRO to BUILD_CDC
Using the broader CDC name instead of AVRO for the CMake variable name
makes more sense as there are modules other than the avrorouter.
2017-02-03 14:39:56 +02:00
Esa Korhonen
eeb3cc436e Remove wildcard domain name matching
This was buggy with the current user database implementation. Need
to think of some other way to implement this feature.
2017-02-01 19:30:42 +02:00
Markus Mäkelä
b23649409f Add comment to GSSAPI insert string
The comment explain why the last two values have no quotes.
2017-01-30 22:41:37 +02:00
Markus Mäkelä
5972d87fba Add missing principal name verification to GSSAPIAuth
The authenticator module did not compare the username with the principal
name that was given by the GSSAPI server.
2017-01-28 10:09:34 +02:00
Esa Korhonen
1f9b18e3bc Split secrets.h to public and core + miscellaneous cleanup
Also, changed some function names to this_style from thisStyle. More of
this in later commits.
2017-01-27 15:33:52 +02:00
Esa Korhonen
7d51864402 Clean config.h some more
Moved some typedefs to router.h and server.h, changed a few
constants to these enums. Renamed some types in config.h to
remove "Gateway".

There are still some functions in the public header which are
only used in core, but they seem to fit the theme of public functions
so were not moved.
2017-01-25 16:05:51 +02:00
Markus Mäkelä
286f44ac80 Fix cdc add_user false error message
The success check was inverted for the adding of a user.
2017-01-25 11:11:42 +02:00
Esa Korhonen
641896872e Rename GW_AUTHENTICATOR and GW_BITMASK + cleanup 2017-01-24 10:03:36 +02:00
Johan Wikman
72aebbdbb3 Add missing include file 2017-01-23 15:29:23 +02:00
Markus Mäkelä
468411250d Fix old header names in modules
Some of the modules still used the gw_authenticator.h name.
2017-01-20 16:57:04 +02:00
Esa Korhonen
6e38276a20 Rename files, removing "gw"-prefix
Also gwdirs.h.in -> paths.h.in
2017-01-20 12:55:52 +02:00
Markus Mäkelä
4869fd98eb Format authenticator modules
Formatted authenticator modules with Astyle.
2017-01-17 14:47:50 +02:00
Markus Mäkelä
5b92a1f467 Remove explicit module name from log messages
The module name doesn't need to be logged as MXS_MODULE_NAME will be
automatically added as a prefix to all messages logged by the module.
2017-01-17 12:51:08 +02:00
Esa Korhonen
936f8c438f Add support for wildcards in hostnames
MXS-391. The user hosts in the SQL backends can now contain wildcard
addresses (e.g.basicuser@%.com or someuser@myhost_.org). Authenticating
these types of users is rather heavy since it requires looking
up the client host name.
2017-01-16 16:10:44 +02:00
Markus Mäkelä
2cabcea211 Add definitions of MXS_MODULE_NAME to all modules
All modules now declare a name for the module. This is name is added as a
prefix to all messages logged by a module. The prefix should help
determine which part of the system logs a message.
2017-01-16 11:28:34 +02:00
Esa Korhonen
1b8742781b MXS-804 Handle hosts of form ip/netmask
Previously, these were discarded. This patch adds a function to
"merge" the mask to the ip so that it's in the form which
normalize_hostname expects (using % as wildcard). Only simple masks
with 255:s and 0:s are accepted. Any other combinations may leave
the hostname in a garbled state which will cause it to be discarded
later.
2017-01-09 10:05:35 +02:00
Johan Wikman
a2a38f952a Add [process|thread] [init|finish] functions to modules
The MXS_MODULDE object now contains optinal pointers for functions
to be called att process and thread startup and shutdown. Since the
functions were added to the end, strictly speaking, all structures
would not have needed to have been modified, but better to be
explicit. In a subsequent change, these will be called.

C++ does not support flexible arrays, so for the time being C++
modules are restricted to 10 parameters. Better approach is to
factor out the parameters to a separate array and then just store
a pointer to that array in MXS_MODULE.
2017-01-05 14:44:02 +02:00
Markus Mäkelä
2e074f4eb4 Introduce common SQLite header
The header declares the missing v2 handle closing function for older
versions of SQLite.
2017-01-05 09:58:11 +02:00
Markus Mäkelä
c96bd64aa8 Rename MODULE_INFO to MXS_MODULE
The MODULE_INFO is now the main object which is used by modules to convey
information to the MaxScale core. The MXS_MODULE name is more apt as it
now contains the actual module definition.

The old MODULES structure was moved into load_utils.c as an internal
implementation and was renamed so that it is not confused with the new
MODULE structure.
2017-01-03 18:01:14 +02:00
Markus Mäkelä
b00e0328d5 Create a macro for module declarations
The modules are now declared with a common macro. This allows future
additions to the module loading process while also making the loaded
symbol name a constant.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
ae0577c695 Move module object inside MODULE_INFO
This allows modules to only expose one entry point with a consistent
signature. In the future, this could be used to implement declarations of
module parameters.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
6c53999c97 Combine ModuleInit and GetModuleObject
The two functions can be combined into one as both are called only
once. This removes the need for the explicit ModuleInit function.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
7df29aa1ec Move version entry point into MODULE_INFO
The MODULE_INFO can easily hold the version information of the
module. This removes the need for a explicit version entry point.
2017-01-03 18:01:13 +02:00
Markus Mäkelä
25c3c33134 Added user creation command to CDCPlainAuth
Users for the CDC protocol can be created through the new `add_user`
module command.
2016-12-23 15:41:48 +02:00
Markus Mäkelä
b9b3bfaa78 Use configured principal name
The default principal name was used instead of the configured one.
2016-12-22 17:55:05 +02:00
Markus Makela
8f86a596fa Add missing linkage to NullAuthAllow
The module did not link against the MySQLCommon library.
2016-12-06 20:27:51 +02:00
Markus Makela
4ae85dc754 Merge branch '2.0' into develop 2016-12-05 21:19:59 +02:00
Markus Makela
b2e11d41d5 MXS-536: Add option to MySQLAuth that skips authentication
Disabling authentication in MaxScale allows creation of users which act
like wildcard users but require that the connection is made through
MaxScale.
2016-12-02 14:28:58 +02:00
Markus Makela
1d9d325a01 MXS-1026: Prevent crash with NullAuth
The authenticator module will not crash but backend authentication will
always fail.
2016-12-02 14:26:43 +02:00
Johan Wikman
1707684992 Move all authenticators into separate subdirectories 2016-12-01 15:43:22 +02:00
Markus Makela
dd63253261 Fix internal test suite failures
The server test used the wrong name.

MySQL users test loaded multiple modules in one function call and wasn't
appropriate for an internal test suite test as it requires a working
installation.

The cache filter didn't set the library paths before trying to load
modules.

The binlogrouter was missing a NULL check which caused a crash.
2016-11-24 15:22:55 +02:00
Johan Wikman
9e4ee0323d Merge branch '2.0' into develop 2016-11-21 12:23:30 +02:00
ekorh475
de4ea067cf Fix for MXS-968
This commit adds a free() to null_auth_free_client_data, which plugs
the memory leak in maxinfo.

Also, this commit fixes some segfaults when multiple threads are
running status_row() or variable_row(). The functions use
statically allocated index variables, which often go out-of-bounds
in concurrent use. This fix changes the indexes to thread-specific
variables, with allocating and deallocating. This does seem to slow
the functions down somewhat.
2016-11-18 18:57:57 +02:00
Markus Makela
3c15b58891 Merge branch '2.0' into develop-2.0-merge 2016-11-15 00:09:24 +02:00