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
59ec0a54
Commit
59ec0a54
authored
2 years ago
by
Davide Vaghetti
Browse files
Options
Downloads
Patches
Plain Diff
Added entity_details script
parent
276be984
No related branches found
Branches containing commit
No related tags found
1 merge request
!6
entity_details
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
entity_details.py
+113
-0
113 additions, 0 deletions
entity_details.py
with
113 additions
and
0 deletions
entity_details.py
0 → 100755
+
113
−
0
View file @
59ec0a54
#!/usr/bin/env python3
import
sys
import
argparse
import
requests
from
xml.etree
import
ElementTree
as
ET
# DEFINE SOME VARS
entity_id
=
None
metadata_file
=
None
root
=
None
tec_contact
=
''
sup_contact
=
''
adm_contact
=
''
# ARGPARSE
parser
=
argparse
.
ArgumentParser
(
description
=
'
Show detailed information about an eduGAIN entity.
'
,
formatter_class
=
argparse
.
RawDescriptionHelpFormatter
,
epilog
=
'''
Examples
- Retrieve details about a single entity using eduGAIN metadata:
\n
./entity_details.py https://idp.dir.garr.it/idp/shibboleth
\n\n
- Retrieve details for a list of idps using a local metadata file:
\n
./entity_details.py -e idp_list -f edugain-v2.xml
'''
)
group
=
parser
.
add_mutually_exclusive_group
()
group
.
add_argument
(
'
ENTITYID
'
,
nargs
=
'
?
'
,
help
=
'
entityID of the entity to look up
'
)
group
.
add_argument
(
'
-e
'
,
type
=
str
,
help
=
'
load entityIDs from file E
'
)
parser
.
add_argument
(
'
-f
'
,
type
=
str
,
help
=
'
load metadata from file F
'
)
parser
.
add_argument
(
'
-u
'
,
type
=
str
,
default
=
'
https://mds.edugain.org/edugain-v2.xml
'
,
help
=
'
download metadata from url U (default to https://mds.edugain.org/edugain-v2.xml)
'
)
args
=
parser
.
parse_args
()
# METHDO TO RETRIVE FED NAME
feds_request
=
requests
.
get
(
"
https://technical.edugain.org/api.php?action=list_feds&format
"
)
feds
=
feds_request
.
json
()
def
get_fed_name
(
registration_authority
):
for
key
in
feds
:
if
feds
[
key
][
'
reg_auth
'
]
==
registration_authority
:
return
feds
[
key
][
'
name
'
]
return
None
# MAIN
entities
=
[]
if
args
.
ENTITYID
:
entities
.
append
(
args
.
ENTITYID
)
elif
args
.
e
:
with
open
(
args
.
e
,
'
r
'
)
as
entitiesfile
:
entities
=
entitiesfile
.
readlines
()
else
:
parser
.
parse_args
([
'
-h
'
])
exit
(
1
)
if
args
.
f
:
tree
=
ET
.
parse
(
args
.
f
)
root
=
tree
.
getroot
()
else
:
xml_req
=
requests
.
get
(
args
.
u
)
root
=
ET
.
fromstring
(
xml_req
.
content
)
orgs
=
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
'
,
'
mdrpi
'
:
'
urn:oasis:names:tc:SAML:metadata:rpi
'
,
}
print
(
'
entityID,FederationName,RegistrationAuthority,OrganizationName,TechnicalContact,SupportContact,AdministrativeContact
'
)
for
entity_id
in
entities
:
entity
=
root
.
find
(
f
'
./md:EntityDescriptor[@entityID=
"
{
entity_id
.
strip
()
}
"
]
'
,
ns
)
if
entity
:
registration_authority
=
None
registration_info
=
entity
.
find
(
'
./md:Extensions/mdrpi:RegistrationInfo
'
,
ns
)
if
registration_info
:
registration_authority
=
registration_info
.
attrib
[
'
registrationAuthority
'
].
strip
()
fed_name
=
get_fed_name
(
registration_authority
)
orgname
=
entity
.
find
(
'
./md:Organization/md:OrganizationDisplayName
'
,
ns
).
text
.
strip
()
tec_contact_el
=
entity
.
find
(
'
./md:ContactPerson[@contactType=
"
technical
"
]/md:EmailAddress
'
,
ns
)
if
tec_contact_el
is
not
None
:
tec_contact
=
tec_contact_el
.
text
.
replace
(
'
mailto:
'
,
''
)
sup_contact_el
=
entity
.
find
(
'
./md:ContactPerson[@contactType=
"
support
"
]/md:EmailAddress
'
,
ns
)
if
sup_contact_el
is
not
None
:
sup_contact
=
sup_contact_el
.
text
.
replace
(
'
mailto:
'
,
''
)
adm_contact_el
=
entity
.
find
(
'
./md:ContactPerson[@contactType=
"
administrative
"
]/md:EmailAddress
'
,
ns
)
if
adm_contact_el
is
not
None
:
adm_contact
=
adm_contact_el
.
text
.
replace
(
'
mailto:
'
,
''
)
print
(
'
{},{},{},{},{},{}
'
.
format
(
entity_id
,
fed_name
,
registration_authority
,
orgname
,
tec_contact
,
sup_contact
,
adm_contact
))
else
:
print
(
f
'
No such entityID:
{
entity_id
}
'
)
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