Bring back page authentication via config.

Inside of the new route handlers the "authenticate" keyword can
be specified to let the route authenticate via a previously
configured authentication block.

The ability to do this went missing in a previous commit that overhauled
the routing structure of the configuration.
This commit is contained in:
Joris Vink 2022-01-31 15:13:34 +01:00
parent 41a4be384e
commit a29700f26d
1 changed files with 22 additions and 0 deletions

View File

@ -113,6 +113,7 @@ static int configure_route_methods(char *);
static int configure_route_handler(char *);
static int configure_route_on_free(char *);
static int configure_route_on_headers(char *);
static int configure_route_authenticate(char *);
static int configure_route_on_body_chunk(char *);
static int configure_filemap(char *);
static int configure_return(char *);
@ -204,6 +205,7 @@ static struct {
{ "on_body_chunk", configure_route_on_body_chunk },
{ "on_free", configure_route_on_free },
{ "methods", configure_route_methods },
{ "authenticate", configure_route_authenticate },
{ "filemap", configure_filemap },
{ "redirect", configure_redirect },
{ "return", configure_return },
@ -1223,6 +1225,26 @@ configure_route_on_free(char *name)
return (KORE_RESULT_OK);
}
static int
configure_route_authenticate(char *name)
{
if (current_route == NULL) {
kore_log(LOG_ERR,
"authenticate keyword not inside of route context");
return (KORE_RESULT_ERROR);
}
current_route->auth = kore_auth_lookup(name);
if (current_route->auth == NULL) {
kore_log(LOG_ERR, "no such authentication '%s' for '%s' found",
name, current_route->path);
return (KORE_RESULT_ERROR);
}
return (KORE_RESULT_OK);
}
static int
configure_route_methods(char *options)
{