[PATCH] Set environment variables for auth filter.

Hugo Hörnquist hugo at lysator.liu.se
Tue Nov 13 13:41:13 CET 2018


Hello again!

A while back I wrote to this list with a problem regarding
environment variables in the authentication filter.
Slightly after I proposed a patch. I'm still interested in
getting this merged.

This patch exposes the CGIT_REPO_* environment variables to
the authentication filters. Which I need for using the
CGIT_REPO_OWNER to give login access. 

I also attached a patch for the documentation, which I
believe should better reflect reality.

-- 
hugo
-------------- next part --------------
>From 2cdefdc06acd658e99c559a9ddaf3f2d3e30b213 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= <hugo at hornquist.se>
Date: Sun, 21 Oct 2018 17:09:33 +0200
Subject: [PATCH 1/2] Set environment flags before auth filters.

---
 cgit.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/cgit.c b/cgit.c
index 6301b87..7a4978e 100644
--- a/cgit.c
+++ b/cgit.c
@@ -1081,6 +1081,9 @@ int cmd_main(int argc, const char **argv)
 		cgit_parse_url(ctx.qry.url);
 	}
 
+	if (ctx.repo)
+		cgit_prepare_repo_env(ctx.repo);
+
 	/* Before we go any further, we set ctx.env.authenticated by checking to see
 	 * if the supplied cookie is valid. All cookies are valid if there is no
 	 * auth_filter. If there is an auth_filter, the filter decides. */
-- 
2.19.1

-------------- next part --------------
>From 6ed1cbc23ae25d1921cd3b20f476729ec620bee2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Hugo=20H=C3=B6rnquist?= <hugo at lysator.liu.se>
Date: Tue, 13 Nov 2018 13:35:50 +0100
Subject: [PATCH 2/2] Update documentation about environment variables.

---
 cgitrc.5.txt | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/cgitrc.5.txt b/cgitrc.5.txt
index 34b351b..8b23a22 100644
--- a/cgitrc.5.txt
+++ b/cgitrc.5.txt
@@ -717,7 +717,8 @@ source filter::
 	filtered contents is expected on standard output.
 
 
-All filters are handed the following environment variables:
+All filters (except for auth-filter, when action is "authenticate-post")
+are handed the following environment variables:
 
 - CGIT_REPO_URL (from repo.url)
 - CGIT_REPO_NAME (from repo.name)
-- 
2.19.1



More information about the CGit mailing list