auth: have cgit calculate login address This way we're sure to use virtual root, or any other strangeness encountered. Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
Jason A. Donenfeld Jason@zx2c4.com
Thu, 16 Jan 2014 23:21:54 +0100
6 files changed,
16 insertions(+),
10 deletions(-)
M
cgit.c
→
cgit.c
@@ -611,7 +611,8 @@ ctx->env.http_host ? ctx->env.http_host : "",
ctx->env.https ? ctx->env.https : "", ctx->qry.repo ? ctx->qry.repo : "", ctx->qry.page ? ctx->qry.page : "", - ctx->qry.url ? ctx->qry.url : ""); + ctx->qry.url ? ctx->qry.url : "", + cgit_loginurl()); } /* We intentionally keep this rather small, instead of looping and
M
cgitrc.5.txt
→
cgitrc.5.txt
@@ -645,7 +645,7 @@ file that is to be filtered is available on standard input and the
filtered contents is expected on standard output. auth filter:: - The authentication filter receives 11 parameters: + The authentication filter receives 12 parameters: - filter action, explained below, which specifies which action the filter is called for - http cookie@@ -656,8 +656,9 @@ - http https flag
- cgit repo - cgit page - cgit url + - cgit login url When the filter action is "body", this filter must write to output the - HTML for displaying the login form, which POSTs to "/?p=login". When + HTML for displaying the login form, which POSTs to the login url. When the filter action is "authenticate-cookie", this filter must validate the http cookie and return a 0 if it is invalid or 1 if it is invalid, in the exit code / close function. If the filter action is
M
filters/simple-authentication.lua
→
filters/simple-authentication.lua
@@ -122,12 +122,7 @@ cgit = {}
cgit["repo"] = select(9, ...) cgit["page"] = select(10, ...) cgit["url"] = select(11, ...) - - cgit["login"] = "" - for _ in cgit["url"]:gfind("/") do - cgit["login"] = cgit["login"] .. "../" - end - cgit["login"] = cgit["login"] .. "?p=login" + cgit["login"] = select(12, ...) end