summaryrefslogtreecommitdiffstats
path: root/org.eclipse.jgit.lfs.server
diff options
context:
space:
mode:
authorDavid Pursehouse <david.pursehouse@gmail.com>2017-02-24 19:26:19 +0900
committerDavid Pursehouse <david.pursehouse@gmail.com>2017-03-08 19:11:03 -0400
commit5094c1a5c853fa04282cfc928f8bd8e0331ca600 (patch)
tree06d262db39aa3e019e2239fd54bd4afecfd4b77d /org.eclipse.jgit.lfs.server
parent993f2b3473a4d47331763bdc187dc5391267af3c (diff)
downloadjgit-5094c1a5c853fa04282cfc928f8bd8e0331ca600.tar.gz
jgit-5094c1a5c853fa04282cfc928f8bd8e0331ca600.zip
LfsProtocolServlet: Pass HTTP Authorization header to getLargeFileRepository
This allows implementations to reject operations that do not include proper authentication. Change-Id: If301476d8fb56a0899e424be3789c7576097d185 Signed-off-by: David Pursehouse <david.pursehouse@gmail.com>
Diffstat (limited to 'org.eclipse.jgit.lfs.server')
-rw-r--r--org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java51
1 files changed, 49 insertions, 2 deletions
diff --git a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java
index e774eba7d2..2473dcdc8c 100644
--- a/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java
+++ b/org.eclipse.jgit.lfs.server/src/org/eclipse/jgit/lfs/server/LfsProtocolServlet.java
@@ -54,6 +54,7 @@ import static org.apache.http.HttpStatus.SC_UNPROCESSABLE_ENTITY;
import static org.eclipse.jgit.lfs.lib.Constants.DOWNLOAD;
import static org.eclipse.jgit.lfs.lib.Constants.UPLOAD;
import static org.eclipse.jgit.lfs.lib.Constants.VERIFY;
+import static org.eclipse.jgit.util.HttpSupport.HDR_AUTHORIZATION;
import java.io.BufferedReader;
import java.io.BufferedWriter;
@@ -143,9 +144,54 @@ public abstract class LfsProtocolServlet extends HttpServlet {
* <dd>when an unexpected internal server error occurred</dd>
* </dl>
* @since 4.5
+ * @deprecated use
+ * {@link #getLargeFileRepository(LfsRequest, String, String)}
+ */
+ @Deprecated
+ protected LargeFileRepository getLargeFileRepository(LfsRequest request,
+ String path) throws LfsException {
+ return getLargeFileRepository(request, path, null);
+ }
+
+ /**
+ * Get the large file repository for the given request and path.
+ *
+ * @param request
+ * the request
+ * @param path
+ * the path
+ * @param auth
+ * the Authorization HTTP header
+ *
+ * @return the large file repository storing large files.
+ * @throws LfsException
+ * implementations should throw more specific exceptions to
+ * signal which type of error occurred:
+ * <dl>
+ * <dt>{@link LfsValidationError}</dt>
+ * <dd>when there is a validation error with one or more of the
+ * objects in the request</dd>
+ * <dt>{@link LfsRepositoryNotFound}</dt>
+ * <dd>when the repository does not exist for the user</dd>
+ * <dt>{@link LfsRepositoryReadOnly}</dt>
+ * <dd>when the user has read, but not write access. Only
+ * applicable when the operation in the request is "upload"</dd>
+ * <dt>{@link LfsRateLimitExceeded}</dt>
+ * <dd>when the user has hit a rate limit with the server</dd>
+ * <dt>{@link LfsBandwidthLimitExceeded}</dt>
+ * <dd>when the bandwidth limit for the user or repository has
+ * been exceeded</dd>
+ * <dt>{@link LfsInsufficientStorage}</dt>
+ * <dd>when there is insufficient storage on the server</dd>
+ * <dt>{@link LfsUnavailable}</dt>
+ * <dd>when LFS is not available</dd>
+ * <dt>{@link LfsException}</dt>
+ * <dd>when an unexpected internal server error occurred</dd>
+ * </dl>
+ * @since 4.7
*/
protected abstract LargeFileRepository getLargeFileRepository(
- LfsRequest request, String path) throws LfsException;
+ LfsRequest request, String path, String auth) throws LfsException;
/**
* LFS request.
@@ -214,7 +260,8 @@ public abstract class LfsProtocolServlet extends HttpServlet {
res.setContentType(CONTENTTYPE_VND_GIT_LFS_JSON);
LargeFileRepository repo = null;
try {
- repo = getLargeFileRepository(request, path);
+ repo = getLargeFileRepository(request, path,
+ req.getHeader(HDR_AUTHORIZATION));
if (repo == null) {
String error = MessageFormat
.format(LfsText.get().lfsFailedToGetRepository, path);