Exemplo n.º 1
0
        protected bool HasAccess(Rpc rpc, bool checkContentType = false)
        {
            if (checkContentType && Request.ContentType != string.Format("application/x-git-{0}-request", rpc.GetDescription())) {
                return false;
            }

            if (rpc == Rpc.ReceivePack) {
                return AppSettings.ReceivePack;
            }

            if (rpc == Rpc.UploadPack) {
                return AppSettings.UploadPack;
            }

            return false;
        }
Exemplo n.º 2
0
        ActionResult ExecuteRpc(string project, Rpc rpc, Action<Repository> action)
        {
            if (!HasAccess(rpc, checkContentType: true)) {
                return new ForbiddenResult();
            }

            Response.ContentType = string.Format("application/x-git-{0}-result", rpc.GetDescription());
            WriteNoCache();

            var repository = repositories.GetRepository(project);

            if (repository == null) {
                return new NotFoundResult();
            }

            using (repository) {
                action(repository);
            }

            return new EmptyResult();
        }