From 1e257c787a4344f242fd941dbfcdb957c7be4ba0 Mon Sep 17 00:00:00 2001 From: Florian Dold Date: Tue, 20 Jul 2021 20:52:58 +0200 Subject: instance auth: refactor, make it serializable --- .../taler-merchant-httpd_private-post-instances.c | 48 +++------------------- 1 file changed, 6 insertions(+), 42 deletions(-) (limited to 'src/backend/taler-merchant-httpd_private-post-instances.c') diff --git a/src/backend/taler-merchant-httpd_private-post-instances.c b/src/backend/taler-merchant-httpd_private-post-instances.c index 71739c3d..4c5919e9 100644 --- a/src/backend/taler-merchant-httpd_private-post-instances.c +++ b/src/backend/taler-merchant-httpd_private-post-instances.c @@ -189,49 +189,13 @@ TMH_private_post_instances (const struct TMH_RequestHandler *rh, } { - bool auth_wellformed = false; - const char *auth_method = json_string_value (json_object_get (jauth, - "method")); + enum GNUNET_GenericReturnValue ret; - if (NULL == auth_method) - { - GNUNET_break_op (0); - } - else if (0 == strcmp (auth_method, - "external")) - { - auth_token = NULL; - auth_wellformed = true; - } - else if (0 == strcmp (auth_method, - "token")) - { - auth_token = json_string_value (json_object_get (jauth, - "token")); - if (NULL == auth_token) - { - GNUNET_break_op (0); - } - else - { - if (0 != strncasecmp (RFC_8959_PREFIX, - auth_token, - strlen (RFC_8959_PREFIX))) - GNUNET_break_op (0); - else - auth_wellformed = true; - } - } - - if (! auth_wellformed) - { - GNUNET_break_op (0); - GNUNET_JSON_parse_free (spec); - return TALER_MHD_reply_with_error (connection, - MHD_HTTP_BAD_REQUEST, - TALER_EC_MERCHANT_PRIVATE_POST_INSTANCES_BAD_AUTH, - "bad authentication config"); - } + ret = TMH_check_auth_config (connection, + jauth, + &auth_token); + if (GNUNET_OK != ret) + return (GNUNET_NO == ret) ? MHD_YES : MHD_NO; } /* check payto_uris for well-formedness */ -- cgit v1.2.3