Implement allowPublicKeyRetrieval option in mysql datasource

This commit is contained in:
Gabriele C 2022-07-18 13:03:05 +02:00
parent d07cb90858
commit 0ac1854a52
3 changed files with 15 additions and 2 deletions

View File

@ -1,5 +1,5 @@
<!-- AUTO-GENERATED FILE! Do not edit this directly -->
<!-- File auto-generated on Sat Dec 25 15:40:26 CET 2021. See docs/config/config.tpl.md -->
<!-- File auto-generated on Mon Jul 18 13:02:11 CEST 2022. See docs/config/config.tpl.md -->
## AuthMe Configuration
The first time you run AuthMe it will create a config.yml file in the plugins/AuthMe folder,
@ -24,6 +24,9 @@ DataSource:
# We would not recommend to set this option to false.
# Set this option to false at your own risk if and only if you know what you're doing
mySQLCheckServerCertificate: true
# Authorize client to retrieve RSA server public key.
# Advanced option, ignore if you don't know what it means.
mySQLAllowPublicKeyRetrieval: true
# Username to connect to the MySQL database
mySQLUsername: authme
# Password to connect to the MySQL database
@ -590,4 +593,4 @@ To change settings on a running server, save your changes to config.yml and use
---
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Sat Dec 25 15:40:26 CET 2021
This page was automatically generated on the [AuthMe/AuthMeReloaded repository](https://github.com/AuthMe/AuthMeReloaded/tree/master/docs/) on Mon Jul 18 13:02:11 CEST 2022

View File

@ -39,6 +39,7 @@ public class MySQL extends AbstractSqlDataSource {
private boolean useSsl;
private boolean serverCertificateVerification;
private boolean allowPublicKeyRetrieval;
private String host;
private String port;
private String username;
@ -118,6 +119,7 @@ public class MySQL extends AbstractSqlDataSource {
this.maxLifetime = settings.getProperty(DatabaseSettings.MYSQL_CONNECTION_MAX_LIFETIME);
this.useSsl = settings.getProperty(DatabaseSettings.MYSQL_USE_SSL);
this.serverCertificateVerification = settings.getProperty(DatabaseSettings.MYSQL_CHECK_SERVER_CERTIFICATE);
this.allowPublicKeyRetrieval = settings.getProperty(DatabaseSettings.MYSQL_ALLOW_PUBLIC_KEY_RETRIEVAL);
}
/**
@ -147,6 +149,9 @@ public class MySQL extends AbstractSqlDataSource {
// Disabling server certificate verification on need
if (!serverCertificateVerification) {
ds.addDataSourceProperty("verifyServerCertificate", String.valueOf(false));
} // Disabling server certificate verification on need
if (allowPublicKeyRetrieval) {
ds.addDataSourceProperty("allowPublicKeyRetrieval", String.valueOf(true));
}
// Encoding

View File

@ -37,6 +37,11 @@ public final class DatabaseSettings implements SettingsHolder {
public static final Property<Boolean> MYSQL_CHECK_SERVER_CERTIFICATE =
newProperty( "DataSource.mySQLCheckServerCertificate", true );
@Comment({"Authorize client to retrieve RSA server public key.",
"Advanced option, ignore if you don't know what it means."})
public static final Property<Boolean> MYSQL_ALLOW_PUBLIC_KEY_RETRIEVAL =
newProperty( "DataSource.mySQLAllowPublicKeyRetrieval", true );
@Comment("Username to connect to the MySQL database")
public static final Property<String> MYSQL_USERNAME =
newProperty("DataSource.mySQLUsername", "authme");