aboutsummaryrefslogtreecommitdiff
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)
downloadgnunet-e44686f08df9c58a90efcaa7322511fce5267bde.tar.gz
gnunet-e44686f08df9c58a90efcaa7322511fce5267bde.zip
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
362GNUNET_STRINGS_urlencode (const char *data, size_t len, char **out); 362GNUNET_STRINGS_urlencode (const char *data, size_t len, char **out);
363 363
364/** 364/**
365 * Decode from Base64url. RFC7515 365 * Encode into Base64url. RFC7515
366 * 366 *
367 * @param data the data to decode 367 * @param in the data to encode
368 * @param len the length of the input 368 * @param len the length of the input
369 * @param output where to write the output (*output should be NULL, 369 * @param output where to write the output (*output should be NULL,
370 * is allocated) 370 * is allocated)
371 * @return the size of the output 371 * @return the size of the output
372 */ 372 */
373size_t 373size_t
374GNUNET_STRINGS_base64url_decode (const char *data, size_t len, void **out); 374GNUNET_STRINGS_base64url_encode (const void *in, size_t len, char **output);
375 375
376 376
377/** 377/**
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 @@
28#include <inttypes.h> 28#include <inttypes.h>
29#include <jansson.h> 29#include <jansson.h>
30 30
31#include "gnunet_buffer_lib.h"
32#include "gnunet_strings_lib.h"
31#include "gnunet_gns_service.h" 33#include "gnunet_gns_service.h"
32#include "gnunet_gnsrecord_lib.h" 34#include "gnunet_gnsrecord_lib.h"
33#include "gnunet_identity_service.h" 35#include "gnunet_identity_service.h"
@@ -855,6 +857,7 @@ login_redirect (void *cls)
855 char *login_base_url; 857 char *login_base_url;
856 char *new_redirect; 858 char *new_redirect;
857 struct MHD_Response *resp; 859 struct MHD_Response *resp;
860 struct GNUNET_Buffer buf = { 0 };
858 struct RequestHandle *handle = cls; 861 struct RequestHandle *handle = cls;
859 862
860 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg, 863 if (GNUNET_OK == GNUNET_CONFIGURATION_get_value_string (cfg,
@@ -862,27 +865,53 @@ login_redirect (void *cls)
862 "address", 865 "address",
863 &login_base_url)) 866 &login_base_url))
864 { 867 {
865 GNUNET_asprintf (&new_redirect, 868 GNUNET_buffer_write (&buf, login_base_url, 1);
866 "%s?%s=%s&%s=%s&%s=%s&%s=%s&%s=%s&%s=%s&%s=%s&%s=%s", 869 GNUNET_buffer_write_fstr (&buf,
867 login_base_url, 870 "?%s=%s",
868 OIDC_RESPONSE_TYPE_KEY, 871 OIDC_RESPONSE_TYPE_KEY,
869 handle->oidc->response_type, 872 handle->oidc->response_type);
870 OIDC_CLIENT_ID_KEY, 873 GNUNET_buffer_write_fstr (&buf,
871 handle->oidc->client_id, 874 "&%s=%s",
872 OIDC_REDIRECT_URI_KEY, 875 OIDC_CLIENT_ID_KEY,
873 handle->oidc->redirect_uri, 876 handle->oidc->client_id);
874 OIDC_SCOPE_KEY, 877 GNUNET_buffer_write_fstr (&buf,
875 handle->oidc->scope, 878 "&%s=%s",
876 OIDC_STATE_KEY, 879 OIDC_REDIRECT_URI_KEY,
877 (NULL != handle->oidc->state) ? handle->oidc->state : "", 880 handle->oidc->redirect_uri);
878 OIDC_CODE_CHALLENGE_KEY, 881
879 (NULL != handle->oidc->code_challenge) ? 882 GNUNET_buffer_write_fstr (&buf,
880 handle->oidc->code_challenge : "", 883 "&%s=%s",
881 OIDC_NONCE_KEY, 884 OIDC_SCOPE_KEY,
882 (NULL != handle->oidc->nonce) ? handle->oidc->nonce : "", 885 handle->oidc->scope);
883 OIDC_CLAIMS_KEY, 886 if (NULL != handle->oidc->state)
884 (NULL != handle->oidc->claims) ? handle->oidc->claims : 887 {
885 ""); 888 GNUNET_buffer_write_fstr (&buf,
889 "&%s=%s",
890 OIDC_STATE_KEY,
891 handle->oidc->state);
892 }
893 if (NULL != handle->oidc->code_challenge)
894 {
895 GNUNET_buffer_write_fstr (&buf,
896 "&%s=%s",
897 OIDC_CODE_CHALLENGE_KEY,
898 handle->oidc->code_challenge);
899 }
900 if (NULL != handle->oidc->nonce)
901 {
902 GNUNET_buffer_write_fstr (&buf,
903 "&%s=%s",
904 OIDC_NONCE_KEY,
905 handle->oidc->nonce);
906 }
907 if (NULL != handle->oidc->claims)
908 {
909 GNUNET_buffer_write_fstr (&buf,
910 "&%s=%s",
911 OIDC_CLAIMS_KEY,
912 handle->oidc->claims);
913 }
914 new_redirect = GNUNET_buffer_reap_str (&buf);
886 resp = GNUNET_REST_create_response (""); 915 resp = GNUNET_REST_create_response ("");
887 MHD_add_response_header (resp, "Location", new_redirect); 916 MHD_add_response_header (resp, "Location", new_redirect);
888 GNUNET_free (login_base_url); 917 GNUNET_free (login_base_url);