mysql
The MySQL backend allows Radiator to authenticate and authorize users against MySQL or MariaDB databases.
Example
mysql "MYSQL_USERS" {
# Database connection URL
url "mysql://radiator:password@localhost:3306/radiator_db";
# SQL query named "FIND_USER"
query "FIND_USER" {
# SQL statement
statement "SELECT username, password_hash FROM users WHERE username = ? AND active = 1";
# Query argument binding in order
bindings {
aaa.identity;
}
# Result value mapping
mapping {
user.username = username;
user.password = password_hash;
}
}
# SQL query for user groups
query "USER_GROUPS" {
# SQL statement with JOIN
statement "SELECT g.groupname FROM groups g INNER JOIN user_groups ug ON g.id = ug.group_id INNER JOIN users u ON ug.user_id = u.id WHERE u.username = ?";
# Query argument binding in order
bindings {
aaa.identity;
}
# Result values mapping
mapping {
user.group += groupname;
}
}
}
Configuration Options
url
This attribute specifies the connection string used to establish a connection with the MySQL database.
MySQL URL format:
mysql://[username[:password]@][host][:port][/database][?param1=value1&...]
query
This clause defines an SQL query operation that retrieves data from the database. The query clause is configured with a name.
Example configuration of a query:
query "AUTHENTICATE_USER" {
# SQL statement with parameter placeholders (?)
statement "SELECT id, username, password_hash, email FROM users WHERE username = ? AND active = 1";
# Query argument binding in order
bindings {
aaa.identity;
}
# Result value mapping
mapping {
user.id = id;
user.username = username;
user.password = password_hash;
user.email = email;
}
}