Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eduGAIN contacts
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
edugain
eduGAIN contacts
Merge requests
!4
added new script for identity federation security contacts
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
added new script for identity federation security contacts
davide.vaghetti/edugain-contacts:master
into
master
Overview
0
Commits
3
Pipelines
0
Changes
1
Merged
Davide Vaghetti
requested to merge
davide.vaghetti/edugain-contacts:master
into
master
4 years ago
Overview
0
Commits
3
Pipelines
0
Changes
1
Expand
0
0
Merge request reports
Viewing commit
1b29eef8
Prev
Next
Show latest version
1 file
+
68
−
0
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
1b29eef8
Moved the edugain_contacts.py script to sirtfi_contacts.py
· 1b29eef8
Davide Vaghetti
authored
4 years ago
sirtfi_contacts.py
0 → 100755
+
68
−
0
Options
#!/usr/bin/env python3
# This script will download the current edugain metadata aggregate XML
# and parse it to derive a list of contacts in CSV format.
# This list will be printed to stdout.
import
requests
from
xml.etree
import
ElementTree
as
ET
def
strip_start
(
s
,
start
):
if
s
.
startswith
(
start
):
return
s
[
len
(
start
):]
return
s
xml_req
=
requests
.
get
(
'
https://mds.edugain.org/edugain-v1.xml
'
)
root
=
ET
.
fromstring
(
xml_req
.
content
)
contacts
=
set
()
seen_doms_mails
=
set
()
ns
=
{
'
md
'
:
'
urn:oasis:names:tc:SAML:2.0:metadata
'
,
'
mdui
'
:
'
urn:oasis:names:tc:SAML:metadata:ui
'
,
'
shibmd
'
:
'
urn:mace:shibboleth:metadata:1.0
'
,
'
remd
'
:
'
http://refeds.org/metadata
'
,
'
icmd
'
:
'
http://id.incommon.org/metadata
'
}
entities
=
root
.
findall
(
'
./md:EntityDescriptor
'
,
ns
)
for
entity
in
entities
:
sec_mails
=
set
()
orgname
=
entity
.
find
(
'
./md:Organization/md:OrganizationDisplayName
'
,
ns
).
text
.
strip
()
if
not
orgname
:
continue
sec_contact_els
=
entity
.
findall
(
'
./md:ContactPerson[@remd:contactType=
"
http://refeds.org/metadata/contactType/security
"
]
'
,
ns
)
+
\
entity
.
findall
(
'
./md:ContactPerson[@icmd:contactType=
"
http://id.incommon.org/metadata/contactType/security
"
]
'
,
ns
)
for
sec_contact_el
in
sec_contact_els
:
mail_el
=
sec_contact_el
.
find
(
'
./md:EmailAddress
'
,
ns
)
name_el
=
sec_contact_el
.
find
(
'
./md:GivenName
'
,
ns
)
surname_el
=
sec_contact_el
.
find
(
'
./md:SurName
'
,
ns
)
if
mail_el
is
None
:
continue
mail
=
strip_start
(
mail_el
.
text
,
'
mailto:
'
)
if
name_el
is
not
None
:
name
=
name_el
.
text
.
strip
()
if
surname_el
is
not
None
:
surname
=
surname_el
.
text
.
strip
()
sec_mails
.
add
(
'"
{} {}
"
<{}>
'
.
format
(
name
,
surname
,
mail
))
else
:
sec_mails
.
add
(
'"
{}
"
<{}>
'
.
format
(
name
,
mail
))
else
:
sec_mails
.
add
(
mail
)
doms
=
entity
.
findall
(
'
./md:IDPSSODescriptor/md:Extensions/shibmd:Scope[@regexp=
"
false
"
]
'
,
ns
)
doms_set
=
set
()
for
dom
in
doms
:
doms_set
.
add
(
dom
.
text
)
for
domain
in
doms_set
:
for
mail
in
sec_mails
:
if
(
domain
,
mail
)
not
in
seen_doms_mails
:
seen_doms_mails
.
add
((
domain
,
mail
))
contacts
.
add
(
'
{},{},{}
'
.
format
(
domain
,
mail
,
orgname
))
for
contact
in
sorted
(
contacts
):
print
(
contact
)
Loading