summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-01 16:22:38 +0200
committerMartin Schanzenbach <mschanzenbach@posteo.de>2020-08-01 16:22:38 +0200
commite44686f08df9c58a90efcaa7322511fce5267bde (patch)
tree681f16883d531b625dcef425c3e766c621b7f3ec
parent2bb07d251cc8eead7a0fcf1c0c7100477f107027 (diff)
fix: reclaim urlenc / revert accidental change
m---------contrib/build-common0
-rw-r--r--src/include/gnunet_strings_lib.h6
-rw-r--r--src/reclaim/plugin_rest_openid_connect.c71
3 files changed, 53 insertions, 24 deletions
diff --git a/contrib/build-common b/contrib/build-common
-Subproject d81bbfabc2538932f631d3946bd6a9b95182b4f
+Subproject d1f949d0cbe30839eb53f34e2a8b34f61e0ad33
diff --git a/src/include/gnunet_strings_lib.h b/src/include/gnunet_strings_lib.h
index bd3ac9dbf..8d829d42e 100644
--- a/src/include/gnunet_strings_lib.h
+++ b/src/include/gnunet_strings_lib.h
@@ -362,16 +362,16 @@ size_t
GNUNET_STRINGS_urlencode (const char *data, size_t len, char **out);
/**
- * Decode from Base64url. RFC7515
+ * Encode into Base64url. RFC7515
*
- * @param data the data to decode
+ * @param in the data to encode
* @param len the length of the input
* @param output where to write the output (*output should be NULL,
* is allocated)
* @return the size of the output
*/
size_t
-GNUNET_STRINGS_base64url_decode (const char *data, size_t len, void **out);
+GNUNET_STRINGS_base64url_encode (const void *in, size_t len, char **output);
/**
diff --git a/src/reclaim/plugin_rest_openid_connect.c b/src/reclaim/plugin_rest_openid_connect.c
index 36ae937c1..4383f16ab 100644
--- a/src/reclaim/plugin_rest_openid_connect.c
+++ b/src/reclaim/plugin_rest_openid_connect.c
@@ -28,6 +28,8 @@
#include <inttypes.h>
#include <jansson.h>
+#include "gnunet_buffer_lib.h"
+#include "gnunet_strings_lib.h"
#include "gnunet_gns_service.h"
#include "gnunet_gnsrecord_lib.h"
#include "gnunet_identity_service.h"
@@ -855,6 +857,7 @@ login_redirect (void *cls)
char *login_base_url;
char *new_redirect;
struct MHD_Response *resp;
+ struct GNUNET_Buffer buf = { 0 };
struct RequestHandle *handle = cls;
if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
@@ -862,27 +865,53 @@ login_redirect (void *cls)
"address",
&login_base_url))
{
- GNUNET_asprintf (&new_redirect,
- "%s?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s&%s=%s&%s=%s&%s=%s",
- login_base_url,
- OIDC_RESPONSE_TYPE_KEY,
- handle->oidc->response_type,
- OIDC_CLIENT_ID_KEY,
- handle->oidc->client_id,
- OIDC_REDIRECT_URI_KEY,
- handle->oidc->redirect_uri,
- OIDC_SCOPE_KEY,
- handle->oidc->scope,
- OIDC_STATE_KEY,
- (NULL != handle->oidc->state) ? handle->oidc->state : "",
- OIDC_CODE_CHALLENGE_KEY,
- (NULL != handle->oidc->code_challenge) ?
- handle->oidc->code_challenge : "",
- OIDC_NONCE_KEY,
- (NULL != handle->oidc->nonce) ? handle->oidc->nonce : "",
- OIDC_CLAIMS_KEY,
- (NULL != handle->oidc->claims) ? handle->oidc->claims :
- "");
+ GNUNET_buffer_write (&buf, login_base_url, 1);
+ GNUNET_buffer_write_fstr (&buf,
+ "?%s=%s",
+ OIDC_RESPONSE_TYPE_KEY,
+ handle->oidc->response_type);
+ GNUNET_buffer_write_fstr (&buf,
+ "&%s=%s",
+ OIDC_CLIENT_ID_KEY,
+ handle->oidc->client_id);
+ GNUNET_buffer_write_fstr (&buf,
+ "&%s=%s",
+ OIDC_REDIRECT_URI_KEY,
+ handle->oidc->redirect_uri);
+
+ GNUNET_buffer_write_fstr (&buf,
+ "&%s=%s",
+ OIDC_SCOPE_KEY,
+ handle->oidc->scope);
+ if (NULL != handle->oidc->state)
+ {
+ GNUNET_buffer_write_fstr (&buf,
+ "&%s=%s",
+ OIDC_STATE_KEY,
+ handle->oidc->state);
+ }
+ if (NULL != handle->oidc->code_challenge)
+ {
+ GNUNET_buffer_write_fstr (&buf,
+ "&%s=%s",
+ OIDC_CODE_CHALLENGE_KEY,
+ handle->oidc->code_challenge);
+ }
+ if (NULL != handle->oidc->nonce)
+ {
+ GNUNET_buffer_write_fstr (&buf,
+ "&%s=%s",
+ OIDC_NONCE_KEY,
+ handle->oidc->nonce);
+ }
+ if (NULL != handle->oidc->claims)
+ {
+ GNUNET_buffer_write_fstr (&buf,
+ "&%s=%s",
+ OIDC_CLAIMS_KEY,
+ handle->oidc->claims);
+ }
+ new_redirect = GNUNET_buffer_reap_str (&buf);
resp = GNUNET_REST_create_response ("");
MHD_add_response_header (resp, "Location", new_redirect);
GNUNET_free (login_base_url);