1
|
|
2
|
import re
|
3
|
|
4
|
from quixote import redirect
|
5
|
|
6
|
from larpe.plugins import site_authentication_plugins
|
7
|
from larpe.site_authentication import SiteAuthentication
|
8
|
|
9
|
class CirilSiteAuthentication(SiteAuthentication):
|
10
|
|
11
|
plugin_name = 'ciril'
|
12
|
output_filters = ['output_ciril_net_rh']
|
13
|
|
14
|
def auto_detect_site(cls, html_doc):
|
15
|
if re.search(
|
16
|
"""<form name="myForm" id="myForm" method="post" target="choixAppli" action="/cgi-bin/acces.exe" """,
|
17
|
html_doc):
|
18
|
return True
|
19
|
return False
|
20
|
auto_detect_site = classmethod(auto_detect_site)
|
21
|
|
22
|
def check_auth(self, status, data):
|
23
|
success = False
|
24
|
return_content = ''
|
25
|
|
26
|
# If status is 500, fail without checking other criterias
|
27
|
if status // 100 == 5:
|
28
|
success = False
|
29
|
return_content = redirect(self.host.get_return_url())
|
30
|
|
31
|
regexp = re.compile(
|
32
|
"""javascript\:window\.open\('(/net_rh/accueil.php\?.*?)', '_blank'\)""",
|
33
|
re.DOTALL | re.IGNORECASE)
|
34
|
match = regexp.findall(data)
|
35
|
if match:
|
36
|
success = True
|
37
|
return_content = redirect(match[0])
|
38
|
|
39
|
return success, return_content
|
40
|
|
41
|
|
42
|
|
43
|
site_authentication_plugins.register(CirilSiteAuthentication)
|
44
|
|