From 720fb7e1babb0c314ba99b5d965e398cdb448b94 Mon Sep 17 00:00:00 2001
From: Davide Vaghetti <davide.vaghetti@garr.it>
Date: Wed, 9 Jun 2021 11:01:00 +0200
Subject: [PATCH] Added script to retrieve identity federations contacts (both
 security and standard)

---
 identity_federations_contacts.py | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100755 identity_federations_contacts.py

diff --git a/identity_federations_contacts.py b/identity_federations_contacts.py
new file mode 100755
index 0000000..7ba5db7
--- /dev/null
+++ b/identity_federations_contacts.py
@@ -0,0 +1,28 @@
+#!/usr/bin/env python3
+
+# This script consume the eduGAIN API to retrieve the details of all the
+# eduGAIN identity federations and parse it to create a list of security
+# email addresses, if available, and the corresponding federation name in
+# CSV format. 
+# This list will be printed to stdout.
+
+import requests
+
+feds = requests.get('https://technical.edugain.org/api.php?action=list_feds_full')
+
+feds_dict = feds.json()
+
+print('FEDERATION,COUNTRIES,SECURITY CONTACT,FEDERATION CONTACT')
+
+for fed in feds_dict:
+    if feds_dict[fed]['status'] == '6':
+        countries = ""
+        security_contact = ""
+        if 'security_contact' in feds_dict[fed]:
+            if 'mail' in feds_dict[fed]['security_contact']:
+                security_contact = feds_dict[fed]['security_contact']['mail']['value']
+        if 'countries' in feds_dict[fed]:
+            countries_array = feds_dict[fed]['countries']
+            for country in countries_array:
+                countries = countries + " " + country
+        print(f"{fed},{countries.strip()},{security_contact},{feds_dict[fed]['contact_email']}")
-- 
GitLab