Use PasswordProvider, fix info on initial passwords in basic security extension docs (#6303)

* Fix info on initial passwords in basic security extension docs

* Use PasswordProvider

* Compile fix
This commit is contained in:
Jonathan Wei 2018-09-05 17:07:16 -07:00 committed by GitHub
parent d61f708ef5
commit 60cbc64472
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 18 deletions

View File

@ -53,8 +53,8 @@ The configuration examples in the rest of this document will use "MyBasicAuthent
#### Properties #### Properties
|Property|Description|Default|required| |Property|Description|Default|required|
|--------|-----------|-------|--------| |--------|-----------|-------|--------|
|`druid.auth.authenticator.MyBasicAuthenticator.initialAdminPassword`|Initial password for the automatically created default admin user. If no password is specified, the default admin user will not be created. If the default admin user already exists, setting this property will affect its password.|null|No| |`druid.auth.authenticator.MyBasicAuthenticator.initialAdminPassword`|Initial [Password Provider](../../operations/password-provider.html) for the automatically created default admin user. If no password is specified, the default admin user will not be created. If the default admin user already exists, setting this property will not affect its password.|null|No|
|`druid.auth.authenticator.MyBasicAuthenticator.initialInternalClientPassword`|Initial password for the default internal system user, used for internal node communication. If no password is specified, the default internal system user will not be created. If the default internal system user already exists, setting this property will affect its password.|null|No| |`druid.auth.authenticator.MyBasicAuthenticator.initialInternalClientPassword`|Initial [Password Provider](../../operations/password-provider.html) for the default internal system user, used for internal node communication. If no password is specified, the default internal system user will not be created. If the default internal system user already exists, setting this property will not affect its password.|null|No|
|`druid.auth.authenticator.MyBasicAuthenticator.enableCacheNotifications`|If true, the coordinator will notify Druid nodes whenever a configuration change to this Authenticator occurs, allowing them to immediately update their state without waiting for polling.|true|No| |`druid.auth.authenticator.MyBasicAuthenticator.enableCacheNotifications`|If true, the coordinator will notify Druid nodes whenever a configuration change to this Authenticator occurs, allowing them to immediately update their state without waiting for polling.|true|No|
|`druid.auth.authenticator.MyBasicAuthenticator.cacheNotificationTimeout`|The timeout in milliseconds for the cache notifications.|5000|No| |`druid.auth.authenticator.MyBasicAuthenticator.cacheNotificationTimeout`|The timeout in milliseconds for the cache notifications.|5000|No|
|`druid.auth.authenticator.MyBasicAuthenticator.credentialIterations`|Number of iterations to use for password hashing.|10000|No| |`druid.auth.authenticator.MyBasicAuthenticator.credentialIterations`|Number of iterations to use for password hashing.|10000|No|

View File

@ -19,19 +19,21 @@
package org.apache.druid.security.basic; package org.apache.druid.security.basic;
import org.apache.druid.metadata.PasswordProvider;
public class BasicAuthDBConfig public class BasicAuthDBConfig
{ {
public static final long DEFAULT_CACHE_NOTIFY_TIMEOUT_MS = 5000; public static final long DEFAULT_CACHE_NOTIFY_TIMEOUT_MS = 5000;
private final String initialAdminPassword; private final PasswordProvider initialAdminPassword;
private final String initialInternalClientPassword; private final PasswordProvider initialInternalClientPassword;
private final boolean enableCacheNotifications; private final boolean enableCacheNotifications;
private final long cacheNotificationTimeout; private final long cacheNotificationTimeout;
private final int iterations; private final int iterations;
public BasicAuthDBConfig( public BasicAuthDBConfig(
final String initialAdminPassword, final PasswordProvider initialAdminPassword,
final String initialInternalClientPassword, final PasswordProvider initialInternalClientPassword,
final Boolean enableCacheNotifications, final Boolean enableCacheNotifications,
final Long cacheNotificationTimeout, final Long cacheNotificationTimeout,
final int iterations final int iterations
@ -44,12 +46,12 @@ public class BasicAuthDBConfig
this.iterations = iterations; this.iterations = iterations;
} }
public String getInitialAdminPassword() public PasswordProvider getInitialAdminPassword()
{ {
return initialAdminPassword; return initialAdminPassword;
} }
public String getInitialInternalClientPassword() public PasswordProvider getInitialInternalClientPassword()
{ {
return initialInternalClientPassword; return initialInternalClientPassword;
} }

View File

@ -25,6 +25,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeName; import com.fasterxml.jackson.annotation.JsonTypeName;
import com.google.inject.Provider; import com.google.inject.Provider;
import org.apache.druid.java.util.common.IAE; import org.apache.druid.java.util.common.IAE;
import org.apache.druid.metadata.PasswordProvider;
import org.apache.druid.security.basic.BasicAuthDBConfig; import org.apache.druid.security.basic.BasicAuthDBConfig;
import org.apache.druid.security.basic.BasicAuthUtils; import org.apache.druid.security.basic.BasicAuthUtils;
import org.apache.druid.security.basic.authentication.db.cache.BasicAuthenticatorCacheManager; import org.apache.druid.security.basic.authentication.db.cache.BasicAuthenticatorCacheManager;
@ -62,8 +63,8 @@ public class BasicHTTPAuthenticator implements Authenticator
@JacksonInject Provider<BasicAuthenticatorCacheManager> cacheManager, @JacksonInject Provider<BasicAuthenticatorCacheManager> cacheManager,
@JsonProperty("name") String name, @JsonProperty("name") String name,
@JsonProperty("authorizerName") String authorizerName, @JsonProperty("authorizerName") String authorizerName,
@JsonProperty("initialAdminPassword") String initialAdminPassword, @JsonProperty("initialAdminPassword") PasswordProvider initialAdminPassword,
@JsonProperty("initialInternalClientPassword") String initialInternalClientPassword, @JsonProperty("initialInternalClientPassword") PasswordProvider initialInternalClientPassword,
@JsonProperty("enableCacheNotifications") Boolean enableCacheNotifications, @JsonProperty("enableCacheNotifications") Boolean enableCacheNotifications,
@JsonProperty("cacheNotificationTimeout") Long cacheNotificationTimeout, @JsonProperty("cacheNotificationTimeout") Long cacheNotificationTimeout,
@JsonProperty("credentialIterations") Integer credentialIterations @JsonProperty("credentialIterations") Integer credentialIterations

View File

@ -138,7 +138,7 @@ public class CoordinatorBasicAuthenticatorMetadataStorageUpdater implements Basi
authenticatorName, authenticatorName,
BasicAuthUtils.ADMIN_NAME, BasicAuthUtils.ADMIN_NAME,
new BasicAuthenticatorCredentialUpdate( new BasicAuthenticatorCredentialUpdate(
dbConfig.getInitialAdminPassword(), dbConfig.getInitialAdminPassword().getPassword(),
BasicAuthUtils.DEFAULT_KEY_ITERATIONS BasicAuthUtils.DEFAULT_KEY_ITERATIONS
) )
); );
@ -151,7 +151,7 @@ public class CoordinatorBasicAuthenticatorMetadataStorageUpdater implements Basi
authenticatorName, authenticatorName,
BasicAuthUtils.INTERNAL_USER_NAME, BasicAuthUtils.INTERNAL_USER_NAME,
new BasicAuthenticatorCredentialUpdate( new BasicAuthenticatorCredentialUpdate(
dbConfig.getInitialInternalClientPassword(), dbConfig.getInitialInternalClientPassword().getPassword(),
BasicAuthUtils.DEFAULT_KEY_ITERATIONS BasicAuthUtils.DEFAULT_KEY_ITERATIONS
) )
); );

View File

@ -23,6 +23,7 @@ import com.google.common.collect.ImmutableMap;
import com.google.inject.Provider; import com.google.inject.Provider;
import com.google.inject.util.Providers; import com.google.inject.util.Providers;
import org.apache.druid.java.util.common.StringUtils; import org.apache.druid.java.util.common.StringUtils;
import org.apache.druid.metadata.DefaultPasswordProvider;
import org.apache.druid.security.basic.authentication.BasicHTTPAuthenticator; import org.apache.druid.security.basic.authentication.BasicHTTPAuthenticator;
import org.apache.druid.security.basic.authentication.db.cache.BasicAuthenticatorCacheManager; import org.apache.druid.security.basic.authentication.db.cache.BasicAuthenticatorCacheManager;
import org.apache.druid.security.basic.authentication.entity.BasicAuthenticatorCredentialUpdate; import org.apache.druid.security.basic.authentication.entity.BasicAuthenticatorCredentialUpdate;
@ -71,8 +72,8 @@ public class BasicHTTPAuthenticatorTest
CACHE_MANAGER_PROVIDER, CACHE_MANAGER_PROVIDER,
"basic", "basic",
"basic", "basic",
"a", new DefaultPasswordProvider("a"),
"a", new DefaultPasswordProvider("a"),
false, false,
null, null,
null null

View File

@ -23,6 +23,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.dataformat.smile.SmileFactory; import com.fasterxml.jackson.dataformat.smile.SmileFactory;
import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet; import com.google.common.collect.ImmutableSet;
import org.apache.druid.metadata.DefaultPasswordProvider;
import org.apache.druid.metadata.MetadataStorageTablesConfig; import org.apache.druid.metadata.MetadataStorageTablesConfig;
import org.apache.druid.metadata.TestDerbyConnector; import org.apache.druid.metadata.TestDerbyConnector;
import org.apache.druid.security.basic.BasicAuthCommonCacheConfig; import org.apache.druid.security.basic.BasicAuthCommonCacheConfig;
@ -83,8 +84,8 @@ public class CoordinatorBasicAuthenticatorResourceTest
null, null,
AUTHENTICATOR_NAME, AUTHENTICATOR_NAME,
"test", "test",
"druid", new DefaultPasswordProvider("druid"),
"druid", new DefaultPasswordProvider("druid"),
null, null,
null, null,
null null
@ -94,8 +95,8 @@ public class CoordinatorBasicAuthenticatorResourceTest
null, null,
AUTHENTICATOR_NAME2, AUTHENTICATOR_NAME2,
"test", "test",
"druid", new DefaultPasswordProvider("druid"),
"druid", new DefaultPasswordProvider("druid"),
null, null,
null, null,
null null