diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2020-12-30 20:58:55 +0900 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2020-12-30 20:58:55 +0900 |
commit | c0465ff926f1b87a375ff320d367cbbabfddb38f (patch) | |
tree | cf32bb93a83235c8175aba682b4437d644bc4ec4 /src/reclaim/oidc_helper.c | |
parent | 3ea7b6e726d80050bc3541e56fc6f9d1a5dbb72a (diff) | |
download | gnunet-c0465ff926f1b87a375ff320d367cbbabfddb38f.tar.gz gnunet-c0465ff926f1b87a375ff320d367cbbabfddb38f.zip |
RECLAIM: Fix quirky OIDC address handling
Diffstat (limited to 'src/reclaim/oidc_helper.c')
-rw-r--r-- | src/reclaim/oidc_helper.c | 57 |
1 files changed, 46 insertions, 11 deletions
diff --git a/src/reclaim/oidc_helper.c b/src/reclaim/oidc_helper.c index 84a90833c..bd3a8ee05 100644 --- a/src/reclaim/oidc_helper.c +++ b/src/reclaim/oidc_helper.c | |||
@@ -223,6 +223,8 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key, | |||
223 | i++; | 223 | i++; |
224 | } | 224 | } |
225 | 225 | ||
226 | int addr_is_aggregated = GNUNET_NO; | ||
227 | int addr_is_normal = GNUNET_NO; | ||
226 | for (le = attrs->list_head; NULL != le; le = le->next) | 228 | for (le = attrs->list_head; NULL != le; le = le->next) |
227 | { | 229 | { |
228 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, | 230 | GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, |
@@ -230,7 +232,6 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key, | |||
230 | le->attribute->name); | 232 | le->attribute->name); |
231 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&le->attribute->credential)) | 233 | if (GNUNET_YES == GNUNET_RECLAIM_id_is_zero (&le->attribute->credential)) |
232 | { | 234 | { |
233 | |||
234 | attr_val_str = | 235 | attr_val_str = |
235 | GNUNET_RECLAIM_attribute_value_to_string (le->attribute->type, | 236 | GNUNET_RECLAIM_attribute_value_to_string (le->attribute->type, |
236 | le->attribute->data, | 237 | le->attribute->data, |
@@ -238,13 +239,22 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key, | |||
238 | /** | 239 | /** |
239 | * There is this wierd quirk that the individual address claim(s) must be | 240 | * There is this wierd quirk that the individual address claim(s) must be |
240 | * inside a JSON object of the "address" claim. | 241 | * inside a JSON object of the "address" claim. |
241 | * FIXME: Possibly include formatted claim here | ||
242 | */ | 242 | */ |
243 | if (GNUNET_YES == is_claim_in_address_scope (le->attribute->name)) | 243 | if (GNUNET_YES == is_claim_in_address_scope (le->attribute->name)) |
244 | { | 244 | { |
245 | if (GNUNET_YES == addr_is_aggregated) | ||
246 | { | ||
247 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
248 | "Address is set as aggregated claim. Skipping self-issued value...\n"); | ||
249 | GNUNET_free (attr_val_str); | ||
250 | continue; | ||
251 | } | ||
252 | addr_is_normal = GNUNET_YES; | ||
253 | |||
245 | if (NULL == addr_claim) | 254 | if (NULL == addr_claim) |
246 | { | 255 | { |
247 | addr_claim = json_object (); | 256 | addr_claim = json_object (); |
257 | json_object_set_new (body, "address", addr_claim); | ||
248 | } | 258 | } |
249 | json_object_set_new (addr_claim, le->attribute->name, | 259 | json_object_set_new (addr_claim, le->attribute->name, |
250 | json_string (attr_val_str)); | 260 | json_string (attr_val_str)); |
@@ -276,17 +286,42 @@ generate_userinfo_json (const struct GNUNET_IDENTITY_PublicKey *sub_key, | |||
276 | le->attribute->name); | 286 | le->attribute->name); |
277 | continue; | 287 | continue; |
278 | } | 288 | } |
279 | // Presentation exists, hence take the respective source str | 289 | /** |
280 | GNUNET_asprintf (&source_name, | 290 | * There is this wierd quirk that the individual address claim(s) must be |
281 | "src%d", | 291 | * inside a JSON object of the "address" claim. |
282 | j); | 292 | */ |
283 | json_object_set_new (aggr_names, le->attribute->name, | 293 | if (GNUNET_YES == is_claim_in_address_scope (le->attribute->name)) |
284 | json_string (source_name)); | 294 | { |
285 | GNUNET_free (source_name); | 295 | if (GNUNET_YES == addr_is_normal) |
296 | { | ||
297 | GNUNET_log (GNUNET_ERROR_TYPE_WARNING, | ||
298 | "Address is already set as normal claim. Skipping attested value...\n"); | ||
299 | continue; | ||
300 | } | ||
301 | addr_is_aggregated = GNUNET_YES; | ||
302 | /** This is/can only be set once! **/ | ||
303 | if (NULL != addr_claim) | ||
304 | continue; | ||
305 | addr_claim = json_object (); | ||
306 | GNUNET_asprintf (&source_name, | ||
307 | "src%d", | ||
308 | j); | ||
309 | json_object_set_new (aggr_names, "address", | ||
310 | json_string (source_name)); | ||
311 | GNUNET_free (source_name); | ||
312 | } | ||
313 | else | ||
314 | { | ||
315 | // Presentation exists, hence take the respective source str | ||
316 | GNUNET_asprintf (&source_name, | ||
317 | "src%d", | ||
318 | j); | ||
319 | json_object_set_new (aggr_names, le->attribute->name, | ||
320 | json_string (source_name)); | ||
321 | GNUNET_free (source_name); | ||
322 | } | ||
286 | } | 323 | } |
287 | } | 324 | } |
288 | if (NULL != addr_claim) | ||
289 | json_object_set_new (body, "address", addr_claim); | ||
290 | if (0 != i) | 325 | if (0 != i) |
291 | { | 326 | { |
292 | json_object_set_new (body, "_claim_names", aggr_names); | 327 | json_object_set_new (body, "_claim_names", aggr_names); |