commit c851cae63bef921a6264a904da1a573bd6f9869a
parent 46b11ac4723a4d85b99ed4212e20b9f833aa6224
Author: Christian Grothoff <christian@grothoff.org>
Date: Mon, 16 Sep 2024 12:58:07 +0200
move from src to main dir, uncrustify
Diffstat:
8 files changed, 197 insertions(+), 193 deletions(-)
diff --git a/src/challenger/.gitignore b/src/challenger/.gitignore
@@ -1,2 +1 @@
challenger-admin
-src/.*
-\ No newline at end of file
diff --git a/src/challenger/Makefile.am b/src/challenger/Makefile.am
@@ -37,7 +37,7 @@ challenger_admin_LDADD = \
$(XLIB)
challenger_httpd_SOURCES = \
- src/challenger_cm_enums.c src/challenger_cm_enums.h \
+ challenger_cm_enums.c challenger_cm_enums.h \
challenger-httpd.c challenger-httpd.h \
challenger-httpd_agpl.c challenger-httpd_agpl.h \
challenger-httpd_spa.c challenger-httpd_spa.h \
diff --git a/src/challenger/challenger-httpd_authorize.c b/src/challenger/challenger-httpd_authorize.c
@@ -25,7 +25,7 @@
#include "challenger-httpd_authorize.h"
#include "challenger-httpd_common.h"
#include "challenger-httpd_spa.h"
-#include "src/challenger_cm_enums.h"
+#include "challenger_cm_enums.h"
/**
* Generate error reply in the format requested by
@@ -145,23 +145,24 @@ CH_handler_authorize (struct CH_HandlerContext *hc,
MHD_GET_ARGUMENT_KIND,
"redirect_uri");
- code_challenge = MHD_lookup_connection_value(hc->connection,
- MHD_GET_ARGUMENT_KIND,
- "code_challenge");
+ code_challenge = MHD_lookup_connection_value (hc->connection,
+ MHD_GET_ARGUMENT_KIND,
+ "code_challenge");
- code_challenge_method = MHD_lookup_connection_value(hc->connection,
- MHD_GET_ARGUMENT_KIND,
- "code_challenge_method");
+ code_challenge_method = MHD_lookup_connection_value (hc->connection,
+ MHD_GET_ARGUMENT_KIND,
+ "code_challenge_method");
- enum CHALLENGER_CM code_challenge_method_enum = CHALLENGER_cm_from_string(code_challenge_method);
+ enum CHALLENGER_CM code_challenge_method_enum = CHALLENGER_cm_from_string (
+ code_challenge_method);
if (CHALLENGER_CM_UNKNOWN == code_challenge_method_enum)
{
- return reply_error(hc,
- "invalid-request",
- MHD_HTTP_BAD_REQUEST,
- TALER_EC_GENERIC_PARAMETER_MALFORMED,
- "Unsupported code_challenge_method, supported only \"plain\", \"S256\".");
+ return reply_error (hc,
+ "invalid-request",
+ MHD_HTTP_BAD_REQUEST,
+ TALER_EC_GENERIC_PARAMETER_MALFORMED,
+ "Unsupported code_challenge_method, supported only \"plain\", \"S256\".");
}
if (NULL != code_challenge)
@@ -180,7 +181,8 @@ CH_handler_authorize (struct CH_HandlerContext *hc,
(0 != strncmp (redirect_uri,
"https://",
strlen ("https://"))) &&
- ( CHALLENGER_CM_EMPTY == code_challenge_method_enum || CHALLENGER_CM_PLAIN == code_challenge_method_enum ) )
+ ((CHALLENGER_CM_EMPTY == code_challenge_method_enum) ||
+ (CHALLENGER_CM_PLAIN == code_challenge_method_enum) ) )
{
GNUNET_break_op (0);
return reply_error (
diff --git a/src/challenger/challenger-httpd_token.c b/src/challenger/challenger-httpd_token.c
@@ -25,7 +25,9 @@
#include "challenger-httpd_common.h"
#include <taler/taler_json_lib.h>
#include <taler/taler_signatures.h>
-#include "src/challenger_cm_enums.h"
+#include "challenger_cm_enums.h"
+
+
/**
* Context for a /token operation.
*/
@@ -371,14 +373,14 @@ CH_handler_token (struct CH_HandlerContext *hc,
char *code;
qs = CH_db->validation_get_pkce (CH_db->cls,
- &bc->nonce,
- &client_secret,
- &address,
- &client_scope,
- &client_state,
- &client_redirect_uri,
- &code_challenge,
- &code_challenge_method);
+ &bc->nonce,
+ &client_secret,
+ &address,
+ &client_scope,
+ &client_state,
+ &client_redirect_uri,
+ &code_challenge,
+ &code_challenge_method);
switch (qs)
{
case GNUNET_DB_STATUS_HARD_ERROR:
@@ -403,11 +405,12 @@ CH_handler_token (struct CH_HandlerContext *hc,
break;
}
- enum CHALLENGER_CM code_challenge_method_enum = CHALLENGER_cm_from_int(code_challenge_method);
+ enum CHALLENGER_CM code_challenge_method_enum = CHALLENGER_cm_from_int (
+ code_challenge_method);
if (CHALLENGER_CM_UNKNOWN == code_challenge_method_enum)
{
- return TALER_MHD_reply_with_error(
+ return TALER_MHD_reply_with_error (
hc->connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
TALER_EC_GENERIC_PARAMETER_MALFORMED,
@@ -426,11 +429,11 @@ CH_handler_token (struct CH_HandlerContext *hc,
GNUNET_free (client_state);
GNUNET_free (code_challenge);
return TALER_MHD_reply_with_oauth_error (
- hc->connection,
- MHD_HTTP_UNAUTHORIZED,
- "invalid_grant",
- TALER_EC_GENERIC_PARAMETER_MISSING,
- "code_verifier is missing");
+ hc->connection,
+ MHD_HTTP_UNAUTHORIZED,
+ "invalid_grant",
+ TALER_EC_GENERIC_PARAMETER_MISSING,
+ "code_verifier is missing");
}
if (CHALLENGER_CM_S256 == code_challenge_method_enum)
@@ -440,37 +443,37 @@ CH_handler_token (struct CH_HandlerContext *hc,
char *encoded_hash = NULL;
size_t encoded_len;
- if(GPG_ERR_NO_ERROR != gcry_md_open(&hd, GCRY_MD_SHA256, 0))
- {
- GNUNET_break_op(0);
- GNUNET_free(client_scope);
- GNUNET_free(client_secret);
- GNUNET_free(client_redirect_uri);
- GNUNET_free(client_state);
- GNUNET_free(code_challenge);
- return TALER_MHD_reply_with_oauth_error(
- hc->connection,
- MHD_HTTP_INTERNAL_SERVER_ERROR,
- "server_error",
- TALER_EC_CHALLENGER_HELPER_EXEC_FAILED,
- "Failed to initialize SHA256 hash function");
- }
- gcry_md_write(hd, bc->code_verifier, strlen(bc->code_verifier));
- memcpy(hash, gcry_md_read(hd, 0), 32);
- gcry_md_close(hd);
+ if (GPG_ERR_NO_ERROR != gcry_md_open (&hd, GCRY_MD_SHA256, 0))
+ {
+ GNUNET_break_op (0);
+ GNUNET_free (client_scope);
+ GNUNET_free (client_secret);
+ GNUNET_free (client_redirect_uri);
+ GNUNET_free (client_state);
+ GNUNET_free (code_challenge);
+ return TALER_MHD_reply_with_oauth_error (
+ hc->connection,
+ MHD_HTTP_INTERNAL_SERVER_ERROR,
+ "server_error",
+ TALER_EC_CHALLENGER_HELPER_EXEC_FAILED,
+ "Failed to initialize SHA256 hash function");
+ }
+ gcry_md_write (hd, bc->code_verifier, strlen (bc->code_verifier));
+ memcpy (hash, gcry_md_read (hd, 0), 32);
+ gcry_md_close (hd);
// Perform base64url encoding
- encoded_len = GNUNET_STRINGS_base64url_encode(hash, 32, &encoded_hash);
-
- if (0 == encoded_len || NULL == encoded_hash)
- {
- GNUNET_break_op(0);
- GNUNET_free(client_scope);
- GNUNET_free(client_secret);
- GNUNET_free(client_redirect_uri);
- GNUNET_free(client_state);
- GNUNET_free(code_challenge);
- return TALER_MHD_reply_with_oauth_error(
+ encoded_len = GNUNET_STRINGS_base64url_encode (hash, 32, &encoded_hash);
+
+ if ((0 == encoded_len) || (NULL == encoded_hash))
+ {
+ GNUNET_break_op (0);
+ GNUNET_free (client_scope);
+ GNUNET_free (client_secret);
+ GNUNET_free (client_redirect_uri);
+ GNUNET_free (client_state);
+ GNUNET_free (code_challenge);
+ return TALER_MHD_reply_with_oauth_error (
hc->connection,
MHD_HTTP_INTERNAL_SERVER_ERROR,
"server_error",
@@ -478,20 +481,20 @@ CH_handler_token (struct CH_HandlerContext *hc,
"Failed to encode hash to Base64 URL");
}
- if (0 != strcmp(encoded_hash, code_challenge))
+ if (0 != strcmp (encoded_hash, code_challenge))
{
- GNUNET_break_op(0);
- GNUNET_free(client_scope);
- GNUNET_free(client_secret);
- GNUNET_free(client_redirect_uri);
- GNUNET_free(client_state);
- GNUNET_free(code_challenge);
- return TALER_MHD_reply_with_oauth_error(
- hc->connection,
- MHD_HTTP_UNAUTHORIZED,
- "invalid_grant",
- TALER_EC_CHALLENGER_CLIENT_FORBIDDEN_BAD_CODE,
- "code_verifier does not match code_challenge");
+ GNUNET_break_op (0);
+ GNUNET_free (client_scope);
+ GNUNET_free (client_secret);
+ GNUNET_free (client_redirect_uri);
+ GNUNET_free (client_state);
+ GNUNET_free (code_challenge);
+ return TALER_MHD_reply_with_oauth_error (
+ hc->connection,
+ MHD_HTTP_UNAUTHORIZED,
+ "invalid_grant",
+ TALER_EC_CHALLENGER_CLIENT_FORBIDDEN_BAD_CODE,
+ "code_verifier does not match code_challenge");
}
}
else if (CHALLENGER_CM_PLAIN == code_challenge_method_enum)
diff --git a/src/challenger/challenger_cm_enums.c b/src/challenger/challenger_cm_enums.c
@@ -0,0 +1,59 @@
+/*
+ This file is part of Challenger
+ Copyright (C) 2023 Taler Systems SA
+
+ Challenger is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ Challenger is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License along with
+ Challenger; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file challenger_cm_enums.c
+ * @brief enums to handle challenge method
+ * @author Bohdan Potuzhnyi
+ * @author Vlada Svirsh
+ */
+
+#include "challenger_cm_enums.h"
+#include <string.h>
+#include <stdint.h>
+
+
+enum CHALLENGER_CM
+CHALLENGER_cm_from_string (const char *method_str)
+{
+ if ((NULL == method_str) || (0 == strcmp (method_str, "")))
+ return CHALLENGER_CM_EMPTY;
+
+ if (0 == strcmp (method_str, "plain"))
+ return CHALLENGER_CM_PLAIN;
+
+ if ((0 == strcmp (method_str, "S256")) || (0 == strcmp (method_str,
+ "sha256")))
+ return CHALLENGER_CM_S256;
+
+ return CHALLENGER_CM_UNKNOWN;
+}
+
+
+enum CHALLENGER_CM
+CHALLENGER_cm_from_int (uint32_t method_int)
+{
+ switch (method_int)
+ {
+ case 0:
+ return CHALLENGER_CM_EMPTY;
+ case 1:
+ return CHALLENGER_CM_PLAIN;
+ case 2:
+ return CHALLENGER_CM_S256;
+ default:
+ return CHALLENGER_CM_UNKNOWN; // Invalid or unrecognized value
+ }
+}
+\ No newline at end of file
diff --git a/src/challenger/challenger_cm_enums.h b/src/challenger/challenger_cm_enums.h
@@ -0,0 +1,58 @@
+/*
+ This file is part of Challenger
+ Copyright (C) 2023 Taler Systems SA
+
+ Challenger is free software; you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free Software
+ Foundation; either version 3, or (at your option) any later version.
+
+ Challenger is distributed in the hope that it will be useful, but WITHOUT ANY
+ WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+ A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License along with
+ Challenger; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
+*/
+/**
+ * @file challenger_cm_enums.h
+ * @brief enums to handle challenge method
+ * @author Bohdan Potuzhnyi
+ * @author Vlada Svirsh
+ */
+
+#ifndef CHALLENGER_CM_ENUMS_H
+#define CHALLENGER_CM_ENUMS_H
+
+#include <stdint.h>
+
+enum CHALLENGER_CM
+{
+ CHALLENGER_CM_EMPTY,
+ CHALLENGER_CM_PLAIN,
+ CHALLENGER_CM_S256,
+ CHALLENGER_CM_UNKNOWN
+};
+
+
+/**
+ * Convert a string to the corresponding enum value.
+ *
+ * @param method_str the string representing the code challenge method
+ * @return the corresponding enum value, or CHALLENGER_CM_UNKNOWN if not recognized
+ */
+enum CHALLENGER_CM
+CHALLENGER_cm_from_string (const char *method_str);
+
+
+/**
+ * Convert an int to the corresponding enum value.
+ * Returns CHALLENGER_CM_UNKNOWN if the int does not match a valid enum value.
+ *
+ * @param method_int integer representation of the code challenge method
+ * @return the corresponding enum value
+ */
+enum CHALLENGER_CM
+CHALLENGER_cm_from_int (uint32_t method_int);
+
+
+#endif /* CHALLENGER_CM_ENUMS_H */
+\ No newline at end of file
diff --git a/src/challenger/src/challenger_cm_enums.c b/src/challenger/src/challenger_cm_enums.c
@@ -1,58 +0,0 @@
-/*
- This file is part of Challenger
- Copyright (C) 2023 Taler Systems SA
-
- Challenger is free software; you can redistribute it and/or modify it under the
- terms of the GNU Affero General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- Challenger is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License along with
- Challenger; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-/**
- * @file challenger_cm_enums.c
- * @brief enums to handle challenge method
- * @author Bohdan Potuzhnyi
- * @author Vlada Svirsh
- */
-
-#include "challenger_cm_enums.h"
-#include <string.h>
-#include <stdint.h>
-
-
-enum CHALLENGER_CM
-CHALLENGER_cm_from_string(const char *method_str)
-{
- if (NULL == method_str || 0 == strcmp(method_str, ""))
- return CHALLENGER_CM_EMPTY;
-
- if (0 == strcmp(method_str, "plain"))
- return CHALLENGER_CM_PLAIN;
-
- if (0 == strcmp(method_str, "S256") || 0 == strcmp(method_str, "sha256"))
- return CHALLENGER_CM_S256;
-
- return CHALLENGER_CM_UNKNOWN;
-}
-
-
-enum CHALLENGER_CM
-CHALLENGER_cm_from_int(uint32_t method_int)
-{
- switch (method_int)
- {
- case 0:
- return CHALLENGER_CM_EMPTY;
- case 1:
- return CHALLENGER_CM_PLAIN;
- case 2:
- return CHALLENGER_CM_S256;
- default:
- return CHALLENGER_CM_UNKNOWN; // Invalid or unrecognized value
- }
-}
-\ No newline at end of file
diff --git a/src/challenger/src/challenger_cm_enums.h b/src/challenger/src/challenger_cm_enums.h
@@ -1,58 +0,0 @@
-/*
- This file is part of Challenger
- Copyright (C) 2023 Taler Systems SA
-
- Challenger is free software; you can redistribute it and/or modify it under the
- terms of the GNU Affero General Public License as published by the Free Software
- Foundation; either version 3, or (at your option) any later version.
-
- Challenger is distributed in the hope that it will be useful, but WITHOUT ANY
- WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
- A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License along with
- Challenger; see the file COPYING. If not, see <http://www.gnu.org/licenses/>
-*/
-/**
- * @file challenger_cm_enums.h
- * @brief enums to handle challenge method
- * @author Bohdan Potuzhnyi
- * @author Vlada Svirsh
- */
-
-#ifndef CHALLENGER_CM_ENUMS_H
-#define CHALLENGER_CM_ENUMS_H
-
-#include <stdint.h>
-
-enum CHALLENGER_CM
-{
- CHALLENGER_CM_EMPTY,
- CHALLENGER_CM_PLAIN,
- CHALLENGER_CM_S256,
- CHALLENGER_CM_UNKNOWN
-};
-
-
-/**
- * Convert a string to the corresponding enum value.
- *
- * @param method_str the string representing the code challenge method
- * @return the corresponding enum value, or CHALLENGER_CM_UNKNOWN if not recognized
- */
-enum CHALLENGER_CM
-CHALLENGER_cm_from_string(const char *method_str);
-
-
-/**
- * Convert an int to the corresponding enum value.
- * Returns CHALLENGER_CM_UNKNOWN if the int does not match a valid enum value.
- *
- * @param method_int integer representation of the code challenge method
- * @return the corresponding enum value
- */
-enum CHALLENGER_CM
-CHALLENGER_cm_from_int(uint32_t method_int);
-
-
-#endif /* CHALLENGER_CM_ENUMS_H */
-\ No newline at end of file