You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nutch.apache.org by le...@apache.org on 2016/07/06 19:33:36 UTC

[1/6] nutch git commit: NUTCH-2284 Basic Authentication support for Nutch 2.X REST API.

Repository: nutch
Updated Branches:
  refs/heads/2.x 7fc92a247 -> 699fda4f4


NUTCH-2284 Basic Authentication support for Nutch 2.X REST API.


Project: http://git-wip-us.apache.org/repos/asf/nutch/repo
Commit: http://git-wip-us.apache.org/repos/asf/nutch/commit/52ffc5a9
Tree: http://git-wip-us.apache.org/repos/asf/nutch/tree/52ffc5a9
Diff: http://git-wip-us.apache.org/repos/asf/nutch/diff/52ffc5a9

Branch: refs/heads/2.x
Commit: 52ffc5a983f261570fd25f10f2f8fcf70d543c88
Parents: 72a99cf
Author: Furkan KAMACI <fu...@gmail.com>
Authored: Sun Jun 19 23:27:15 2016 +0300
Committer: Furkan KAMACI <fu...@gmail.com>
Committed: Sun Jun 19 23:27:55 2016 +0300

----------------------------------------------------------------------
 conf/nutch-default.xml                         | 26 ++++++++++++++++++++
 src/java/org/apache/nutch/api/NutchServer.java | 27 +++++++++++++++++++--
 2 files changed, 51 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nutch/blob/52ffc5a9/conf/nutch-default.xml
----------------------------------------------------------------------
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xml
index 117737b..f5111f7 100644
--- a/conf/nutch-default.xml
+++ b/conf/nutch-default.xml
@@ -1435,4 +1435,30 @@
   </description>
 </property>
 
+<property>
+  <name>restapi.auth</name>
+  <value>false</value>
+  <description>
+    Whether to enable HTTP basic authentication for communicating with RESTAPI.
+    Use the restapi.auth.username and restapi.auth.auth.password properties to configure
+    your credentials.
+  </description>
+</property>
+
+<property>
+  <name>restapi.auth.username</name>
+  <value>login</value>
+  <description>
+    Username for HTTP basic authentication. restapi.auth should be true to use this property.
+  </description>
+</property>
+
+<property>
+  <name>restapi.auth.password</name>
+  <value>secret1</value>
+  <description>
+    Password for HTTP basic authentication. restapi.auth should be true to use this property.
+  </description>
+</property>
+
 </configuration>

http://git-wip-us.apache.org/repos/asf/nutch/blob/52ffc5a9/src/java/org/apache/nutch/api/NutchServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/nutch/api/NutchServer.java b/src/java/org/apache/nutch/api/NutchServer.java
index ea316a9..3429beb 100644
--- a/src/java/org/apache/nutch/api/NutchServer.java
+++ b/src/java/org/apache/nutch/api/NutchServer.java
@@ -45,10 +45,13 @@ import org.apache.nutch.api.resources.JobResource;
 import org.apache.nutch.api.resources.SeedResource;
 import org.restlet.Component;
 import org.restlet.Context;
+import org.restlet.data.ChallengeScheme;
 import org.restlet.data.Protocol;
 import org.restlet.data.Reference;
 import org.restlet.ext.jaxrs.JaxRsApplication;
 import org.restlet.resource.ClientResource;
+import org.restlet.security.ChallengeAuthenticator;
+import org.restlet.security.MapVerifier;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -108,8 +111,28 @@ public class NutchServer extends Application {
     application.setStatusService(new ErrorStatusService());
     childContext.getAttributes().put(NUTCH_SERVER, this);
 
-    // Attach the application.
-    component.getDefaultHost().attach(application);
+    boolean isSecure = configManager.get(ConfigResource.DEFAULT).getBoolean("restapi.auth", false);
+
+    if (!isSecure) {
+      // Attach the application.
+      component.getDefaultHost().attach(application);
+      return;
+    }
+
+    // Guard the restlet with BASIC authentication.
+    ChallengeAuthenticator guard = new ChallengeAuthenticator(null, ChallengeScheme.HTTP_BASIC, "testRealm");
+    // Instantiates a Verifier of identifier/secret couples based on a simple Map.
+    MapVerifier mapVerifier = new MapVerifier();
+
+    // Load a single static login/secret pair.
+    String username = configManager.get(ConfigResource.DEFAULT).get("restapi.auth.username", "login");
+    String password = configManager.get(ConfigResource.DEFAULT).get("restapi.auth.password", "secret");
+
+    mapVerifier.getLocalSecrets().put(username, password.toCharArray());
+    guard.setVerifier(mapVerifier);
+    guard.setNext(application);
+
+    component.getDefaultHost().attach(guard);
   }
 
   @Override


[4/6] nutch git commit: NUTCH-2284 HTML escape characters are used at javadoc.

Posted by le...@apache.org.
NUTCH-2284 HTML escape characters are used at javadoc.


Project: http://git-wip-us.apache.org/repos/asf/nutch/repo
Commit: http://git-wip-us.apache.org/repos/asf/nutch/commit/4d1e9e31
Tree: http://git-wip-us.apache.org/repos/asf/nutch/tree/4d1e9e31
Diff: http://git-wip-us.apache.org/repos/asf/nutch/diff/4d1e9e31

Branch: refs/heads/2.x
Commit: 4d1e9e31395091f1677388feaed6f6f3fd6d6cd3
Parents: 6a82525
Author: Furkan KAMACI <fu...@gmail.com>
Authored: Mon Jul 4 14:08:22 2016 +0300
Committer: Furkan KAMACI <fu...@gmail.com>
Committed: Mon Jul 4 14:08:22 2016 +0300

----------------------------------------------------------------------
 src/java/org/apache/nutch/api/NutchServer.java | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nutch/blob/4d1e9e31/src/java/org/apache/nutch/api/NutchServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/nutch/api/NutchServer.java b/src/java/org/apache/nutch/api/NutchServer.java
index 969ec16..6af991c 100644
--- a/src/java/org/apache/nutch/api/NutchServer.java
+++ b/src/java/org/apache/nutch/api/NutchServer.java
@@ -88,9 +88,9 @@ public class NutchServer extends Application {
    * well as the logging granularity. If the latter option is not provided via
    * {@link org.apache.nutch.api.NutchServer#main(String[])} then it defaults to
    * 'INFO' however best attempts should always be made to specify a logging
-   * level.<br>
+   * level.&lt;br&gt;
    * {@link org.apache.nutch.api.NutchServer} can be run as secure. restapi.auth property
-   * should be set to true at <code>nutch-site.xml</code> to enable HTTP basic authentication
+   * should be set to true at &lt;code&gt;nutch-site.xml&lt;/code&gt; to enable HTTP basic authentication
    * for communicating with RESTAPI.
    * Use the restapi.auth.username and restapi.auth.auth.password properties to configure
    * your credentials.


[2/6] nutch git commit: NUTCH-2284 Javadoc is updated to explain how to use Basic Authentication.

Posted by le...@apache.org.
NUTCH-2284 Javadoc is updated to explain how to use Basic Authentication.


Project: http://git-wip-us.apache.org/repos/asf/nutch/repo
Commit: http://git-wip-us.apache.org/repos/asf/nutch/commit/fc2b80f5
Tree: http://git-wip-us.apache.org/repos/asf/nutch/tree/fc2b80f5
Diff: http://git-wip-us.apache.org/repos/asf/nutch/diff/fc2b80f5

Branch: refs/heads/2.x
Commit: fc2b80f595c684cdabe07e115001ebd24c185981
Parents: 52ffc5a
Author: Furkan KAMACI <fu...@gmail.com>
Authored: Sat Jun 25 14:24:10 2016 +0300
Committer: Furkan KAMACI <fu...@gmail.com>
Committed: Sat Jun 25 14:24:10 2016 +0300

----------------------------------------------------------------------
 src/java/org/apache/nutch/api/NutchServer.java | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nutch/blob/fc2b80f5/src/java/org/apache/nutch/api/NutchServer.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/nutch/api/NutchServer.java b/src/java/org/apache/nutch/api/NutchServer.java
index 3429beb..969ec16 100644
--- a/src/java/org/apache/nutch/api/NutchServer.java
+++ b/src/java/org/apache/nutch/api/NutchServer.java
@@ -88,7 +88,12 @@ public class NutchServer extends Application {
    * well as the logging granularity. If the latter option is not provided via
    * {@link org.apache.nutch.api.NutchServer#main(String[])} then it defaults to
    * 'INFO' however best attempts should always be made to specify a logging
-   * level.
+   * level.<br>
+   * {@link org.apache.nutch.api.NutchServer} can be run as secure. restapi.auth property
+   * should be set to true at <code>nutch-site.xml</code> to enable HTTP basic authentication
+   * for communicating with RESTAPI.
+   * Use the restapi.auth.username and restapi.auth.auth.password properties to configure
+   * your credentials.
    */
   public NutchServer() {
     configManager = new RAMConfManager();


[6/6] nutch git commit: Merge branch 'NUTCH-2284' of https://github.com/kamaci/nutch into 2.x this closes #124

Posted by le...@apache.org.
Merge branch 'NUTCH-2284' of https://github.com/kamaci/nutch into 2.x this closes #124


Project: http://git-wip-us.apache.org/repos/asf/nutch/repo
Commit: http://git-wip-us.apache.org/repos/asf/nutch/commit/699fda4f
Tree: http://git-wip-us.apache.org/repos/asf/nutch/tree/699fda4f
Diff: http://git-wip-us.apache.org/repos/asf/nutch/diff/699fda4f

Branch: refs/heads/2.x
Commit: 699fda4f4edf808198e85b5dfe60cdcc686b8ab7
Parents: 7fc92a2 8e2552e
Author: Lewis John McGibbney <le...@gmail.com>
Authored: Wed Jul 6 12:39:26 2016 -0700
Committer: Lewis John McGibbney <le...@gmail.com>
Committed: Wed Jul 6 12:39:26 2016 -0700

----------------------------------------------------------------------
 conf/nutch-default.xml                         | 28 +++++++++++++++++
 src/java/org/apache/nutch/api/NutchServer.java | 34 +++++++++++++++++++--
 2 files changed, 59 insertions(+), 3 deletions(-)
----------------------------------------------------------------------



[3/6] nutch git commit: NUTCH-2284 Typo is fixed at restapi.auth property's description.

Posted by le...@apache.org.
NUTCH-2284 Typo is fixed at restapi.auth property's description.


Project: http://git-wip-us.apache.org/repos/asf/nutch/repo
Commit: http://git-wip-us.apache.org/repos/asf/nutch/commit/6a82525d
Tree: http://git-wip-us.apache.org/repos/asf/nutch/tree/6a82525d
Diff: http://git-wip-us.apache.org/repos/asf/nutch/diff/6a82525d

Branch: refs/heads/2.x
Commit: 6a82525dba62bf1d67582dc272727675e6fb113a
Parents: fc2b80f
Author: Furkan KAMACI <fu...@gmail.com>
Authored: Sun Jul 3 15:10:25 2016 +0300
Committer: Furkan KAMACI <fu...@gmail.com>
Committed: Sun Jul 3 15:10:25 2016 +0300

----------------------------------------------------------------------
 conf/nutch-default.xml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nutch/blob/6a82525d/conf/nutch-default.xml
----------------------------------------------------------------------
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xml
index f5111f7..ff22b63 100644
--- a/conf/nutch-default.xml
+++ b/conf/nutch-default.xml
@@ -1440,7 +1440,7 @@
   <value>false</value>
   <description>
     Whether to enable HTTP basic authentication for communicating with RESTAPI.
-    Use the restapi.auth.username and restapi.auth.auth.password properties to configure
+    Use the restapi.auth.username and restapi.auth.password properties to configure
     your credentials.
   </description>
 </property>


[5/6] nutch git commit: NUTCH-2284 nutch-default.xml descriptions for restapi.auth.username and restapi.auth.password are updated.

Posted by le...@apache.org.
NUTCH-2284 nutch-default.xml descriptions for restapi.auth.username and restapi.auth.password are updated.


Project: http://git-wip-us.apache.org/repos/asf/nutch/repo
Commit: http://git-wip-us.apache.org/repos/asf/nutch/commit/8e2552e8
Tree: http://git-wip-us.apache.org/repos/asf/nutch/tree/8e2552e8
Diff: http://git-wip-us.apache.org/repos/asf/nutch/diff/8e2552e8

Branch: refs/heads/2.x
Commit: 8e2552e88999d19a599844559a98888c646b62fb
Parents: 4d1e9e3
Author: Furkan KAMACI <fu...@gmail.com>
Authored: Mon Jul 4 14:19:38 2016 +0300
Committer: Furkan KAMACI <fu...@gmail.com>
Committed: Mon Jul 4 14:19:38 2016 +0300

----------------------------------------------------------------------
 conf/nutch-default.xml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/nutch/blob/8e2552e8/conf/nutch-default.xml
----------------------------------------------------------------------
diff --git a/conf/nutch-default.xml b/conf/nutch-default.xml
index ff22b63..1985dfc 100644
--- a/conf/nutch-default.xml
+++ b/conf/nutch-default.xml
@@ -1450,14 +1450,16 @@
   <value>login</value>
   <description>
     Username for HTTP basic authentication. restapi.auth should be true to use this property.
+    "login" is used for username as default.
   </description>
 </property>
 
 <property>
   <name>restapi.auth.password</name>
-  <value>secret1</value>
+  <value>secret</value>
   <description>
     Password for HTTP basic authentication. restapi.auth should be true to use this property.
+    "secret" is used for password as default.
   </description>
 </property>