Skip to content

Commit

Permalink
0000918: Add startup parameters to support basic authentication
Browse files Browse the repository at this point in the history
  • Loading branch information
chenson42 committed Nov 20, 2012
1 parent 9591230 commit 5cdbe3f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 9 deletions.
17 changes: 8 additions & 9 deletions symmetric-assemble/src/docbook/advanced-topics.xml
Expand Up @@ -978,6 +978,8 @@ Enter key password for <sym>
<title>Basic Authentication</title>
<para>
SymmetricDS supports basic authentication for client and server nodes.
</para>
<para>
To configure a client node to use basic authentication when communicating with a server node,
specify the following startup parameters:
</para>
Expand Down Expand Up @@ -1006,31 +1008,28 @@ Enter key password for <sym>
</varlistentry>
</variablelist>
<para>
The SymmetricDS Standalone and Embedded Server also support basic authentication.
This feature is enabled by specifying the basic authentication username and
password using the following startup parameters:
The SymmetricDS Standalone Web Server also supports Basic Authentication. It can be enabled by
passing the following arguments to the startup program
</para>
<variablelist>
<varlistentry>
<term>
<command>embedded.webserver.basic.auth.username</command>
<command>--http-basic-auth-user</command>
</term>
<listitem>
<para>
username for basic authentication for an embedded server
or standalone server node.
username for basic authentication
[&#xA0;Default:&#xA0;]
</para>
</listitem>
</varlistentry>
<varlistentry>
<term>
<command>embedded.webserver.basic.auth.password</command>
<command>--http-basic-auth-password</command>
</term>
<listitem>
<para>
password for basic authentication for an embedded server
or standalone server node.
password for basic authentication
[&#xA0;Default:&#xA0;]
</para>
</listitem>
Expand Down
Expand Up @@ -25,6 +25,8 @@ Launcher.Option.secure-port=Optionally pass in the HTTPS port number to use for
Launcher.Option.max-idle-time=Max idle time in milliseconds when a connection is forced to close [900000].
Launcher.Option.no-nio=Do not use Non-blocking IO for the HTTP connector.
Launcher.Option.no-directbuffer=Do not use direct buffers for the NIO HTTP connector.
Launcher.Option.http-basic-auth-user=Setting this option and --http-basic-auth-password will force the server to require basic authentication for all operations.
Launcher.Option.http-basic-auth-password=Setting this option and --http-basic-auth-user will force the server to require basic authentication for all operations.

SymAdmin.Cmd.reload-node=Reload data at a node (or initial load)
SymAdmin.Cmd.reload-table=Reload data at a node for a table
Expand Down
Expand Up @@ -37,6 +37,10 @@ public class SymmetricLauncher extends AbstractCommandLauncher {
private static final String OPTION_PORT_SERVER = "port";

private static final String OPTION_HOST_SERVER = "host";

private static final String OPTION_HTTP_BASIC_AUTH_USER = "http-basic-auth-user";

private static final String OPTION_HTTP_BASIC_AUTH_PASSWORD = "http-basic-auth-password";

private static final String OPTION_SECURE_PORT_SERVER = "secure-port";

Expand Down Expand Up @@ -93,6 +97,8 @@ protected void buildOptions(Options options) {
addOption(options, "I", OPTION_MAX_IDLE_TIME, true);
addOption(options, "nnio", OPTION_NO_NIO, false);
addOption(options, "ndb", OPTION_NO_DIRECT_BUFFER, false);
addOption(options, "hbau", OPTION_HTTP_BASIC_AUTH_USER, true);
addOption(options, "hbap", OPTION_HTTP_BASIC_AUTH_PASSWORD, true);
}

protected boolean executeWithOptions(CommandLine line) throws Exception {
Expand All @@ -104,9 +110,17 @@ protected boolean executeWithOptions(CommandLine line) throws Exception {
int maxIdleTime = SymmetricWebServer.DEFAULT_MAX_IDLE_TIME;
boolean noNio = false;
boolean noDirectBuffer = false;
String httpBasicAuthUser = null;
String httpBasicAuthPassword = null;

configureCrypto(line);

if (line.hasOption(OPTION_HTTP_BASIC_AUTH_USER) &&
line.hasOption(OPTION_HTTP_BASIC_AUTH_PASSWORD)) {
httpBasicAuthUser = line.getOptionValue(OPTION_HTTP_BASIC_AUTH_USER);
httpBasicAuthPassword = line.getOptionValue(OPTION_HTTP_BASIC_AUTH_PASSWORD);
}

if (line.hasOption(OPTION_HOST_SERVER)) {
host = line.getOptionValue(OPTION_HOST_SERVER);
}
Expand Down Expand Up @@ -139,6 +153,8 @@ protected boolean executeWithOptions(CommandLine line) throws Exception {
maxIdleTime, propertiesFile != null ? propertiesFile.getCanonicalPath() : null,
true, noNio, noDirectBuffer);
webServer.setHost(host);
webServer.setBasicAuthUsername(httpBasicAuthUser);
webServer.setBasicAuthPassword(httpBasicAuthPassword);
if (line.hasOption(OPTION_START_MIXED_SERVER)) {
webServer.startMixed(port, securePort);
} else if (line.hasOption(OPTION_START_SECURE_SERVER)) {
Expand Down

0 comments on commit 5cdbe3f

Please sign in to comment.