summaryrefslogtreecommitdiff
path: root/src/backend/taler-merchant-httpd_private-post-instances.c
diff options
context:
space:
mode:
authorFlorian Dold <florian@dold.me>2021-07-20 20:52:58 +0200
committerFlorian Dold <florian@dold.me>2021-07-20 20:52:58 +0200
commit1e257c787a4344f242fd941dbfcdb957c7be4ba0 (patch)
treefa3b1db2e00cb7d088a958538b49cd17537660b4 /src/backend/taler-merchant-httpd_private-post-instances.c
parent9a89fbb3440325344e8029340ce409ba9418dc3d (diff)
downloadmerchant-1e257c787a4344f242fd941dbfcdb957c7be4ba0.tar.gz
merchant-1e257c787a4344f242fd941dbfcdb957c7be4ba0.tar.bz2
merchant-1e257c787a4344f242fd941dbfcdb957c7be4ba0.zip
instance auth: refactor, make it serializable
Diffstat (limited to 'src/backend/taler-merchant-httpd_private-post-instances.c')
-rw-r--r--src/backend/taler-merchant-httpd_private-post-instances.c48
1 files changed, 6 insertions, 42 deletions
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 */