GUACAMOLE-708: Add properties for automatic account creation.

This commit is contained in:
Virtually Nick
2020-06-19 12:22:26 -04:00
parent 6d89c1a308
commit 0ad00dda3e
11 changed files with 70 additions and 5 deletions

View File

@@ -151,5 +151,21 @@ public abstract class JDBCEnvironment extends LocalEnvironment {
* true if the database supports recursive queries, false otherwise. * true if the database supports recursive queries, false otherwise.
*/ */
public abstract boolean isRecursiveQuerySupported(SqlSession session); public abstract boolean isRecursiveQuerySupported(SqlSession session);
/**
* Returns a boolean value representing whether or not the JDBC module
* should automatically create accounts within the database for users that
* are successfully authenticated via other extensions. Returns true if
* accounts should be auto-created, otherwise returns false.
*
* @return
* true if user accounts should be automatically created within the
* database when authentication succeeds from another extension;
* otherwise false.
*
* @throws GuacamoleException
* If guacamole.properties cannot be parsed.
*/
public abstract boolean autoCreateAbsentAccounts() throws GuacamoleException;
} }

View File

@@ -386,5 +386,11 @@ public class MySQLEnvironment extends JDBCEnvironment {
public String getMYSQLSSLClientPassword() throws GuacamoleException { public String getMYSQLSSLClientPassword() throws GuacamoleException {
return getProperty(MySQLGuacamoleProperties.MYSQL_SSL_TRUST_PASSWORD); return getProperty(MySQLGuacamoleProperties.MYSQL_SSL_TRUST_PASSWORD);
} }
@Override
public boolean autoCreateAbsentAccounts() throws GuacamoleException {
return getProperty(MySQLGuacamoleProperties.MYSQL_AUTO_CREATE_ACCOUNTS,
false);
}
} }

View File

@@ -240,5 +240,13 @@ public class MySQLGuacamoleProperties {
public String getName() { return "mysql-ssl-client-password"; } public String getName() { return "mysql-ssl-client-password"; }
}; };
public static final BooleanGuacamoleProperty MYSQL_AUTO_CREATE_ACCOUNTS =
new BooleanGuacamoleProperty() {
@Override
public String getName() { return "mysql-auto-create-accounts"; }
};
} }

View File

@@ -328,4 +328,10 @@ public class PostgreSQLEnvironment extends JDBCEnvironment {
return getProperty(PostgreSQLGuacamoleProperties.POSTGRESQL_SSL_KEY_PASSWORD); return getProperty(PostgreSQLGuacamoleProperties.POSTGRESQL_SSL_KEY_PASSWORD);
} }
@Override
public boolean autoCreateAbsentAccounts() throws GuacamoleException {
return getProperty(PostgreSQLGuacamoleProperties.POSTGRESQL_AUTO_CREATE_ACCOUNTS,
false);
}
} }

View File

@@ -233,4 +233,16 @@ public class PostgreSQLGuacamoleProperties {
}; };
/**
* Whether or not the PostgreSQL extension should automatically add database
* entries for users who are granted access through other extensions.
*/
public static final BooleanGuacamoleProperty POSTGRESQL_AUTO_CREATE_ACCOUNTS =
new BooleanGuacamoleProperty() {
@Override
public String getName() { return "postgresql-auto-create-accounts"; }
};
} }

View File

@@ -25,6 +25,8 @@ import com.google.inject.name.Names;
import java.lang.UnsupportedOperationException; import java.lang.UnsupportedOperationException;
import java.util.Properties; import java.util.Properties;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.auth.sqlserver.conf.SQLServerDriver;
import org.apache.guacamole.auth.sqlserver.conf.SQLServerEnvironment;
import org.mybatis.guice.datasource.helper.JdbcHelper; import org.mybatis.guice.datasource.helper.JdbcHelper;
/** /**
@@ -45,7 +47,7 @@ public class SQLServerAuthenticationProviderModule implements Module {
/** /**
* Which SQL Server driver should be used. * Which SQL Server driver should be used.
*/ */
private SQLServerDriver sqlServerDriver; private final SQLServerDriver sqlServerDriver;
/** /**
* Creates a new SQLServer authentication provider module that configures * Creates a new SQLServer authentication provider module that configures

View File

@@ -24,6 +24,7 @@ import com.google.inject.Injector;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.auth.jdbc.JDBCAuthenticationProviderModule; import org.apache.guacamole.auth.jdbc.JDBCAuthenticationProviderModule;
import org.apache.guacamole.auth.jdbc.JDBCInjectorProvider; import org.apache.guacamole.auth.jdbc.JDBCInjectorProvider;
import org.apache.guacamole.auth.sqlserver.conf.SQLServerEnvironment;
/** /**
* JDBCInjectorProvider implementation which configures Guice injections for * JDBCInjectorProvider implementation which configures Guice injections for

View File

@@ -17,7 +17,7 @@
* under the License. * under the License.
*/ */
package org.apache.guacamole.auth.sqlserver; package org.apache.guacamole.auth.sqlserver.conf;
import org.apache.guacamole.properties.EnumGuacamoleProperty.PropertyValue; import org.apache.guacamole.properties.EnumGuacamoleProperty.PropertyValue;

View File

@@ -17,7 +17,7 @@
* under the License. * under the License.
*/ */
package org.apache.guacamole.auth.sqlserver; package org.apache.guacamole.auth.sqlserver.conf;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.auth.jdbc.JDBCEnvironment; import org.apache.guacamole.auth.jdbc.JDBCEnvironment;
@@ -273,5 +273,11 @@ public class SQLServerEnvironment extends JDBCEnvironment {
public boolean isRecursiveQuerySupported(SqlSession session) { public boolean isRecursiveQuerySupported(SqlSession session) {
return true; // All versions of SQL Server support recursive queries through CTEs return true; // All versions of SQL Server support recursive queries through CTEs
} }
@Override
public boolean autoCreateAbsentAccounts() throws GuacamoleException {
return getProperty(SQLServerGuacamoleProperties.SQLSERVER_AUTO_CREATE_ACCOUNTS,
false);
}
} }

View File

@@ -17,7 +17,7 @@
* under the License. * under the License.
*/ */
package org.apache.guacamole.auth.sqlserver; package org.apache.guacamole.auth.sqlserver.conf;
import org.apache.guacamole.properties.BooleanGuacamoleProperty; import org.apache.guacamole.properties.BooleanGuacamoleProperty;
import org.apache.guacamole.properties.EnumGuacamoleProperty; import org.apache.guacamole.properties.EnumGuacamoleProperty;
@@ -193,5 +193,13 @@ public class SQLServerGuacamoleProperties {
public String getName() { return "sqlserver-driver"; } public String getName() { return "sqlserver-driver"; }
}; };
public static final BooleanGuacamoleProperty SQLSERVER_AUTO_CREATE_ACCOUNTS =
new BooleanGuacamoleProperty() {
@Override
public String getName() { return "sqlserver-auto-create-accounts"; }
};
} }

View File

@@ -17,7 +17,7 @@
* under the License. * under the License.
*/ */
package org.apache.guacamole.auth.sqlserver; package org.apache.guacamole.auth.sqlserver.conf;
import org.apache.guacamole.GuacamoleException; import org.apache.guacamole.GuacamoleException;
import org.apache.guacamole.auth.jdbc.JDBCEnvironment; import org.apache.guacamole.auth.jdbc.JDBCEnvironment;