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
Commits
b64f09b4
Commit
b64f09b4
authored
4 years ago
by
Davide Vaghetti
Browse files
Options
Downloads
Patches
Plain Diff
Added support for multiple security contacts
parent
e8eaf73f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!3
Added support for multiple security contacts
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
edugain_contacts.py
+27
-26
27 additions, 26 deletions
edugain_contacts.py
with
27 additions
and
26 deletions
edugain_contacts.py
+
27
−
26
View file @
b64f09b4
...
...
@@ -19,7 +19,7 @@ xml_req = requests.get('https://mds.edugain.org/edugain-v1.xml')
root
=
ET
.
fromstring
(
xml_req
.
content
)
contacts
=
set
()
seen_doms
=
set
()
seen_doms
_mails
=
set
()
ns
=
{
'
md
'
:
'
urn:oasis:names:tc:SAML:2.0:metadata
'
,
...
...
@@ -33,36 +33,37 @@ ns = {
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
contact
=
entity
.
find
(
'
./md:ContactPerson[@remd:contactType=
"
http://refeds.org/metadata/contactType/security
"
]
'
,
ns
)
if
contact
is
None
:
contact
=
entity
.
find
(
'
./md:ContactPerson[@icmd:contactType=
"
http://id.incommon.org/metadata/contactType/security
"
]
'
,
ns
)
if
contact
is
None
:
continue
mail_el
=
contact
.
find
(
'
./md:EmailAddress
'
,
ns
)
if
mail_el
is
None
:
continue
name_el
=
contact
.
find
(
'
./md:GivenName
'
,
ns
)
surname_el
=
contact
.
find
(
'
./md:SurName
'
,
ns
)
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
()
contact_txt
=
'"
{} {}
"
<{}>
'
.
format
(
name
,
surname
,
mail
)
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
:
contact_txt
=
'"
{}
"
<{}>
'
.
format
(
name
,
mail
)
else
:
contact_txt
=
mail
sec_mails
.
add
(
mail
)
doms
=
entity
.
findall
(
'
./md:IDPSSODescriptor/md:Extensions/shibmd:Scope[@regexp=
"
false
"
]
'
,
ns
)
for
domain
in
doms
:
domain_text
=
domain
.
text
if
domain_text
not
in
seen_doms
:
seen_doms
.
add
(
domain_text
)
contacts
.
add
(
'
{},{},{}
'
.
format
(
domain_text
,
contact_txt
,
orgname
))
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
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment