kore

Kore is a web application platform for writing scalable, concurrent web based processes in C or Python.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit a29700f26d01fe1e6ed138e2ea5a8e6d5810054f
parent 41a4be384e631988bc94f11aa0d33c4d1943576f
Author: Joris Vink <joris@coders.se>
Date:   Mon, 31 Jan 2022 15:13:34 +0100

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.

Diffstat:
src/config.c | 22++++++++++++++++++++++
1 file changed, 22 insertions(+), 0 deletions(-)

diff --git a/src/config.c b/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 }, @@ -1224,6 +1226,26 @@ configure_route_on_free(char *name) } 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) { int i, cnt;