List for cgit developers and users
 help / color / mirror / Atom feed
* CGIT_REPO_* environment variables in auth filter?
@ 2018-10-20 16:00 
  2018-10-21 15:20 ` 
  0 siblings, 1 reply; 2+ messages in thread
From:  @ 2018-10-20 16:00 UTC (permalink / raw)


Hi!

The manual (cgitrc(5)) states that "All filters are handed
the following environment variable:" and lists the different
CGIT_REPO_* variables. I'm trying to access them from an
auth filter written in lua (a slight modification of the
included simple-authentication.lua) but they are all unset.

I have tested running cgit through nginx, lighttpd and
directly. And none of them worked. Is there something I'm
missing? Or is this by design and the documentation is
wrong?

The variables are however available in a shell-script
source-filter.

Thanks in advance for the help.

-- 
hugo


^ permalink raw reply	[flat|nested] 2+ messages in thread

* CGIT_REPO_* environment variables in auth filter?
  2018-10-20 16:00 CGIT_REPO_* environment variables in auth filter? 
@ 2018-10-21 15:20 ` 
  0 siblings, 0 replies; 2+ messages in thread
From:  @ 2018-10-21 15:20 UTC (permalink / raw)


I started reading the source myself, and found that
cgit_prepare_repo_env is called after all authentication
filters.

The diff below shows a possible fix. It does however only
apply for authenticate-cookie and body, and not
authenticate-post (apparently due to the repo only being
loaded in the former two cases). 

	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. */

On Sat, Oct 20, 2018 at 06:00:52PM +0200, Hugo H?rnquist wrote:
> Hi!
> 
> The manual (cgitrc(5)) states that "All filters are handed
> the following environment variable:" and lists the different
> CGIT_REPO_* variables. I'm trying to access them from an
> auth filter written in lua (a slight modification of the
> included simple-authentication.lua) but they are all unset.
> 
> I have tested running cgit through nginx, lighttpd and
> directly. And none of them worked. Is there something I'm
> missing? Or is this by design and the documentation is
> wrong?
> 
> The variables are however available in a shell-script
> source-filter.
> 
> Thanks in advance for the help.
> 
> -- 
> hugo
> _______________________________________________
> CGit mailing list
> CGit at lists.zx2c4.com
> https://lists.zx2c4.com/mailman/listinfo/cgit

-- 
hugo


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-10-21 15:20 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-20 16:00 CGIT_REPO_* environment variables in auth filter? 
2018-10-21 15:20 ` 

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).