diff --git a/pom.xml b/pom.xml index 21f666ea03..7062bd24de 100644 --- a/pom.xml +++ b/pom.xml @@ -36,7 +36,7 @@
+ * Set this to false to avoid getting Basic auth dialogue popups in browsers
+ * when using the public API directly, for example.
+ *
+ * @see REPO-2575
+ * @param useBasicAuth
+ */
+ public void setUseBasicAuth(boolean useBasicAuth)
+ {
+ this.useBasicAuth = useBasicAuth;
+ }
+
public void setTenantAuthentication(TenantAuthentication service)
{
this.tenantAuthentication = service;
@@ -232,7 +250,9 @@ public class PublicApiAuthenticatorFactory extends RemoteUserAuthenticatorFactor
if (!authorized)
{
servletRes.setStatus(401);
- servletRes.setHeader("WWW-Authenticate", "Basic realm=\"Alfresco " + servletReq.getTenant() + " tenant\"");
+ String scheme = useBasicAuth ? "Basic" : "AlfTicket";
+ String challenge = scheme + " realm=\"Alfresco " + servletReq.getTenant() + " tenant\"";
+ servletRes.setHeader("WWW-Authenticate", challenge);
}
}
}
diff --git a/src/main/resources/alfresco/project-remote-api.properties b/src/main/resources/alfresco/project-remote-api.properties
new file mode 100644
index 0000000000..90aa30f32e
--- /dev/null
+++ b/src/main/resources/alfresco/project-remote-api.properties
@@ -0,0 +1,24 @@
+################################################################################
+# Remote API property defaults
+# 9th October 2017
+################################################################################
+
+
+# Whether to send a "basic auth" challenge along with a 401 response (not authorized)
+#
+# If set to true, then a header will be sent similar to:
+#
+# WWW-Authenticate: Basic realm="..."
+#
+# If set to false, then a header will be sent with an AlfTicket challenge:
+#
+# WWW-Authenticate: AlfTicket realm="..."
+#
+# This latter case is particularly useful when building a web-browser based client
+# that communicates directly with the Alfresco Public API - using the AlfTicket
+# challenge allows the client to completely control the login behaviour, whereas
+# allowing a Basic auth challenge to be sent results in the Basic Authentication
+# browser dialogue being popped-up without the client app being involved.
+#
+# See issue REPO-2575 for details.
+alfresco.restApi.basicAuthScheme=true
diff --git a/src/main/resources/alfresco/public-rest-context.xml b/src/main/resources/alfresco/public-rest-context.xml
index 997a45b348..641894a2a1 100644
--- a/src/main/resources/alfresco/public-rest-context.xml
+++ b/src/main/resources/alfresco/public-rest-context.xml
@@ -95,6 +95,7 @@