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
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
- 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
switch (filtertype) {
case AUTH:
- argument_count = 11;
+ argument_count = 12;
break;
case EMAIL:
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
return ctx.cfg.script_name;
}
+const char *cgit_loginurl()
+{
+ static const char *login_url = 0;
+ if (!login_url)
+ login_url = fmtalloc("%s?p=login", cgit_rooturl());
+ return login_url;
+}
+
char *cgit_repourl(const char *reponame)
{
if (ctx.cfg.virtual_root)
extern const char *cgit_httpscheme();
extern const char *cgit_hosturl();
extern const char *cgit_rooturl();
+extern const char *cgit_loginurl();
extern char *cgit_repourl(const char *reponame);
extern char *cgit_fileurl(const char *reponame, const char *pagename,
const char *filename, const char *query);