Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
eduGAIN Connectivity Check
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 Connectivity Check
Commits
7bc48f56
Commit
7bc48f56
authored
5 years ago
by
Marco Malavolti
Browse files
Options
Downloads
Patches
Plain Diff
Added 'extractFederation.py'
parent
1b1648a7
No related branches found
No related tags found
No related merge requests found
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
eccs2.py
+53
-50
53 additions, 50 deletions
eccs2.py
extractFederation.py
+38
-0
38 additions, 0 deletions
extractFederation.py
list_eccs_idps-idem.txt
+1
-0
1 addition, 0 deletions
list_eccs_idps-idem.txt
with
93 additions
and
50 deletions
.gitignore
+
1
−
0
View file @
7bc48f56
selenium_chromedriver.log
selenium_chromedriver.log
*.swp
*.swp
*.txt
This diff is collapsed.
Click to expand it.
eccs2.py
+
53
−
50
View file @
7bc48f56
#!/usr/bin/env python3
#!/usr/bin/env python3
from
selenium
import
webdriver
from
selenium.webdriver.common.by
import
By
from
selenium.webdriver.support.ui
import
Select
from
selenium.webdriver.common.keys
import
Keys
from
selenium.common.exceptions
import
NoSuchElementException
from
selenium.common.exceptions
import
TimeoutException
from
datetime
import
date
from
datetime
import
date
import
logging
import
logging
...
@@ -25,7 +19,8 @@ def logFile(idp,content):
...
@@ -25,7 +19,8 @@ def logFile(idp,content):
f
.
close
()
f
.
close
()
def
getIdPs
():
def
getIdpListFromUrl
():
import
certifi
import
certifi
import
urllib3
import
urllib3
import
json
import
json
...
@@ -36,27 +31,60 @@ def getIdPs():
...
@@ -36,27 +31,60 @@ def getIdPs():
)
)
url
=
"
https://technical.edugain.org/api.php?action=list_eccs_idps
"
url
=
"
https://technical.edugain.org/api.php?action=list_eccs_idps
"
idp_json
=
manager
.
request
(
'
GET
'
,
url
)
json_data
=
manager
.
request
(
'
GET
'
,
url
)
data
=
json
.
loads
(
json_data
.
data
.
decode
(
'
utf-8
'
))
idp_dict
=
json
.
loads
(
idp_json
.
data
.
decode
(
'
utf-8
'
))
return
data
idp_list
=
[]
for
idp
in
idp_dict
:
def
getIdpListFromFile
()
:
i
dp_list
.
append
(
idp
[
'
displayname
'
].
split
(
'
;
'
)[
1
].
split
(
'
==
'
)[
0
])
i
mport
json
return
idp_list
with
open
(
'
list_eccs_idps-idem.txt
'
)
as
f
:
json_data
=
json
.
loads
(
f
.
read
())
return
json_data
def
checkIdP
(
sp
,
idp
,
logger
):
def
checkIdP
(
sp
,
idp
,
logger
):
from
selenium
import
webdriver
from
selenium.webdriver.common.by
import
By
from
selenium.webdriver.support.ui
import
Select
from
selenium.webdriver.common.keys
import
Keys
from
selenium.common.exceptions
import
NoSuchElementException
from
selenium.common.exceptions
import
TimeoutException
import
re
import
re
driver
=
setup
()
# Configure Web-driver
chrome_options
=
webdriver
.
ChromeOptions
()
chrome_options
.
add_argument
(
'
--headless
'
)
chrome_options
.
add_argument
(
'
--no-sandbox
'
)
# driver = webdriver.Chrome('chromedriver', chrome_options=chrome_options, service_args=['--verbose', '--log-path=./selenium_chromedriver.log'])
driver
=
webdriver
.
Chrome
(
'
chromedriver
'
,
chrome_options
=
chrome_options
)
# Configure timeouts: 45 sec
driver
.
set_page_load_timeout
(
45
)
driver
.
set_script_timeout
(
45
)
# Configure Blacklists
federation_blacklist
=
[
'
http://www.surfconext.nl/
'
,
'
https://www.wayf.dk
'
,
'
http://feide.no/
'
]
entities_blacklist
=
[
'
https://idp.eie.gr/idp/shibboleth
'
,
'
https://gn-vho.grnet.gr/idp/shibboleth
'
,
'
https://wtc.tu-chemnitz.de/shibboleth
'
,
'
https://wtc.tu-chemnitz.de/shibboleth
'
,
'
https://idp.fraunhofer.de/idp/shibboleth
'
,
'
https://login.hs-owl.de/nidp/saml2/metadata
'
,
'
https://idp.dfn-cert.de/idp/shibboleth
'
]
if
(
idp
[
'
entityID
'
]
in
entities_blacklist
):
logger
.
info
(
"
%s;%s;IdP excluded from checks
"
)
driver
.
close
()
driver
.
quit
()
return
"
Disabled
"
if
(
idp
[
'
registrationAuthority
'
]
in
federation_blacklist
):
logger
.
info
(
"
%s;%s;Federation excluded from checks
"
)
driver
.
close
()
driver
.
quit
()
return
"
Disabled
"
# Open SP, select the IDP from the EDS and press 'Enter' to reach the IdP login page to check
# Open SP, select the IDP from the EDS and press 'Enter' to reach the IdP login page to check
try
:
try
:
driver
.
get
(
sp
)
driver
.
get
(
sp
)
driver
.
find_element_by_id
(
"
idpSelectInput
"
).
send_keys
(
idp
+
Keys
.
ENTER
)
driver
.
find_element_by_id
(
"
idpSelectInput
"
).
send_keys
(
idp
[
'
entityID
'
]
+
Keys
.
ENTER
)
driver
.
find_element_by_id
(
"
username
"
)
driver
.
find_element_by_id
(
"
username
"
)
driver
.
find_element_by_id
(
"
password
"
)
driver
.
find_element_by_id
(
"
password
"
)
...
@@ -64,7 +92,7 @@ def checkIdP(sp,idp,logger):
...
@@ -64,7 +92,7 @@ def checkIdP(sp,idp,logger):
except
NoSuchElementException
as
e
:
except
NoSuchElementException
as
e
:
pass
pass
except
TimeoutException
as
e
:
except
TimeoutException
as
e
:
logger
.
info
(
"
%s;%s;TIMEOUT
"
%
(
idp
,
sp
))
logger
.
info
(
"
%s;%s;TIMEOUT
"
%
(
idp
[
'
entityID
'
]
,
sp
))
driver
.
close
()
driver
.
close
()
driver
.
quit
()
driver
.
quit
()
return
"
TIMEOUT
"
return
"
TIMEOUT
"
...
@@ -79,36 +107,21 @@ def checkIdP(sp,idp,logger):
...
@@ -79,36 +107,21 @@ def checkIdP(sp,idp,logger):
password_found
=
re
.
search
(
pattern_password
,
driver
.
page_source
,
re
.
I
)
password_found
=
re
.
search
(
pattern_password
,
driver
.
page_source
,
re
.
I
)
if
(
metadata_not_found
):
if
(
metadata_not_found
):
logger
.
info
(
"
%s;%s;No-eduGAIN-Metadata
"
%
(
idp
,
sp
))
logger
.
info
(
"
%s;%s;No-eduGAIN-Metadata
"
%
(
idp
[
'
entityID
'
]
,
sp
))
driver
.
close
()
driver
.
close
()
driver
.
quit
()
driver
.
quit
()
return
"
No-eduGAIN-Metadata
"
return
"
No-eduGAIN-Metadata
"
elif
not
username_found
and
not
password_found
:
elif
not
username_found
and
not
password_found
:
logger
.
info
(
"
%s;%s;Invalid-Form
"
%
(
idp
,
sp
))
logger
.
info
(
"
%s;%s;Invalid-Form
"
%
(
idp
[
'
entityID
'
]
,
sp
))
driver
.
close
()
driver
.
close
()
driver
.
quit
()
driver
.
quit
()
return
"
Invalid Form
"
return
"
Invalid Form
"
else
:
else
:
logger
.
info
(
"
%s;%s;OK
"
%
(
idp
,
sp
))
logger
.
info
(
"
%s;%s;OK
"
%
(
idp
[
'
entityID
'
]
,
sp
))
driver
.
close
()
driver
.
close
()
driver
.
quit
()
driver
.
quit
()
return
"
OK
"
return
"
OK
"
# Setup Chromium Webdriver
def
setup
():
chrome_options
=
webdriver
.
ChromeOptions
()
chrome_options
.
add_argument
(
'
--headless
'
)
chrome_options
.
add_argument
(
'
--no-sandbox
'
)
# driver = webdriver.Chrome('chromedriver', chrome_options=chrome_options, service_args=['--verbose', '--log-path=./selenium_chromedriver.log'])
driver
=
webdriver
.
Chrome
(
'
chromedriver
'
,
chrome_options
=
chrome_options
)
# Configure timeouts
driver
.
set_page_load_timeout
(
45
)
driver
.
set_script_timeout
(
45
)
return
driver
# Use logger to produce files consumed by ECCS-2 API
# Use logger to produce files consumed by ECCS-2 API
def
getLogger
(
filename
,
log_level
=
"
DEBUG
"
,
path
=
"
./
"
):
def
getLogger
(
filename
,
log_level
=
"
DEBUG
"
,
path
=
"
./
"
):
...
@@ -146,20 +159,8 @@ if __name__=="__main__":
...
@@ -146,20 +159,8 @@ if __name__=="__main__":
sps
=
[
"
https://sp24-test.garr.it/secure
"
,
"
https://attribute-viewer.aai.switch.ch/eds/
"
]
sps
=
[
"
https://sp24-test.garr.it/secure
"
,
"
https://attribute-viewer.aai.switch.ch/eds/
"
]
# listIdPsTest = [
#listIdPs = getIdpListFromUrl()
# 'University of Utah',
listIdPs
=
getIdpListFromFile
()
# 'Nanjing Agriculture University',
# 'Fujian Normal University',
# 'SUIBE',
# 'Zuyd Hogeschool',
# 'Sur University College',
# 'https://idp.hec.gov.pk/idp/shibboleth',
# 'https://login.itsak.gr/idp/shibboleth',
# 'https://idp.eastdurham.ac.uk/openathens',
# 'https://idp-lib.nwafu.edu.cn/idp/shibboleth',
# ]
listIdPs
=
getIdPs
()
for
idp
in
listIdPs
:
for
idp
in
listIdPs
:
result
=
[]
result
=
[]
...
@@ -168,7 +169,9 @@ if __name__=="__main__":
...
@@ -168,7 +169,9 @@ if __name__=="__main__":
# If all checks are 'OK', than the IdP consuming correctly eduGAIN Metadata.
# If all checks are 'OK', than the IdP consuming correctly eduGAIN Metadata.
if
(
result
[
0
]
==
result
[
1
]
==
"
OK
"
):
if
(
result
[
0
]
==
result
[
1
]
==
"
OK
"
):
eccs2log
.
info
(
"
IdP
'
%s
'
results into: OK
"
%
(
idp
))
eccs2log
.
info
(
"
IdP
'
%s
'
results: OK
"
%
(
idp
[
'
entityID
'
]))
elif
(
result
[
0
]
==
result
[
1
]
==
"
DISABLED
"
):
eccs2log
.
info
(
"
IdP
'
%s
'
results: DISABLED
"
%
(
idp
[
'
entityID
'
]))
else
:
else
:
eccs2log
.
info
(
"
IdP
'
%s
'
results
into: NOT OK
"
%
(
idp
))
eccs2log
.
info
(
"
IdP
'
%s
'
results
: ERROR
"
%
(
idp
[
'
entityID
'
]
))
This diff is collapsed.
Click to expand it.
extractFederation.py
0 → 100755
+
38
−
0
View file @
7bc48f56
#!/usr/bin/env python3
def
getIdPs
():
import
certifi
import
urllib3
import
json
manager
=
urllib3
.
PoolManager
(
cert_reqs
=
'
CERT_REQUIRED
'
,
ca_certs
=
certifi
.
where
()
)
url
=
"
https://technical.edugain.org/api.php?action=list_eccs_idps
"
idp_json
=
manager
.
request
(
'
GET
'
,
url
)
idp_dict
=
json
.
loads
(
idp_json
.
data
.
decode
(
'
utf-8
'
))
idp_list
=
[]
#federation = input("Insert the registrationAuthority: ")
federation
=
"
http://www.idem.garr.it/
"
for
idp
in
idp_dict
:
if
(
idp
[
'
registrationAuthority
'
]
==
federation
):
idp_list
.
append
(
idp
)
return
json
.
dumps
(
idp_list
)
# MAIN
if
__name__
==
"
__main__
"
:
data
=
getIdPs
()
f
=
open
(
'
federation_idps.txt
'
,
'
w
'
)
f
.
write
(
data
)
f
.
close
()
This diff is collapsed.
Click to expand it.
list_eccs_idps-idem.txt
0 → 100644
+
1
−
0
View file @
7bc48f56
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