[
https://issues.apache.org/jira/browse/EAGLE-621?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15580029#comment-15580029
]
ASF GitHub Bot commented on EAGLE-621:
--------------------------------------
Github user haoch commented on a diff in the pull request:
https://github.com/apache/incubator-eagle/pull/514#discussion_r83551893
--- Diff:
eagle-server/src/main/java/org/apache/eagle/server/authentication/BasicAuthProviderBuilder.java
---
@@ -0,0 +1,61 @@
+package org.apache.eagle.server.authentication;
+
+import com.google.common.cache.CacheBuilderSpec;
+import com.sun.jersey.api.core.HttpContext;
+import com.sun.jersey.api.model.Parameter;
+import com.sun.jersey.core.spi.component.ComponentContext;
+import com.sun.jersey.server.impl.inject.AbstractHttpContextInjectable;
+import com.sun.jersey.spi.inject.Injectable;
+import io.dropwizard.auth.Auth;
+import io.dropwizard.auth.Authenticator;
+import io.dropwizard.auth.CachingAuthenticator;
+import io.dropwizard.auth.basic.BasicAuthProvider;
+import io.dropwizard.auth.basic.BasicCredentials;
+import io.dropwizard.setup.Environment;
+import org.apache.eagle.common.authentication.User;
+import
org.apache.eagle.server.authentication.authenticator.LdapBasicAuthenticator;
+import
org.apache.eagle.server.authentication.authenticator.SimpleBasicAuthenticator;
+import
org.apache.eagle.server.authentication.config.AuthenticationSettings;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class BasicAuthProviderBuilder {
+ private static final String SIMPLE_MODE_REALM =
"SIMPLE_AUTHENTICATION";
+ private static final String LDAP_MODE_REALM = "LDAP_AUTHENTICATION";
+ private static final Map<String, BasicAuthProvider<User>> MAPPING =
new HashMap<>();
+ private AuthenticationSettings authSettings;
+ private Environment environment;
+
+ public BasicAuthProviderBuilder(AuthenticationSettings authSettings,
Environment environment) {
+ this.authSettings = authSettings;
+ this.environment = environment;
+ Authenticator<BasicCredentials, User> simpleAuthenticator = new
SimpleBasicAuthenticator(authSettings.getSimple());
+ Authenticator<BasicCredentials, User> ldapAuthenticator = new
LdapBasicAuthenticator(authSettings.getLdap());
+ boolean needsCaching = authSettings.needsCaching();
--- End diff --
Better to register static object in static scope instead of in instance
constructor, and move check `needsCaching` to `build` method.
> set authentication disabled by default when no 'auth' is configured in
> configuration.yml
> ----------------------------------------------------------------------------------------
>
> Key: EAGLE-621
> URL: https://issues.apache.org/jira/browse/EAGLE-621
> Project: Eagle
> Issue Type: Task
> Reporter: Michael Wu
> Assignee: Michael Wu
>
> Eagle's authentication configuration is set in config file, and we need to
> set auth-service as disabled by default, especially when there is no 'auth'
> and descendant param set.
> Also this may affect auth registration code structure, it need refactoring.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)