mirror of
https://github.com/jorisvink/kore
synced 2025-03-09 04:29:02 -04:00
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:
parent
41a4be384e
commit
a29700f26d
22
src/config.c
22
src/config.c
@ -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)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user