Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F61367275
external_authentication.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Mon, May 6, 05:42
Size
2 KB
Mime Type
text/x-python
Expires
Wed, May 8, 05:42 (2 d)
Engine
blob
Format
Raw Data
Handle
17502011
Attached To
R3600 invenio-infoscience
external_authentication.py
View Options
## $Id$
## CDS Invenio Access Control Config in mod_python.
## This file is part of CDS Invenio.
## Copyright (C) 2002, 2003, 2004, 2005, 2006 CERN.
##
## CDS Invenio is free software; you can redistribute it and/or
## modify it under the terms of the GNU General Public License as
## published by the Free Software Foundation; either version 2 of the
## License, or (at your option) any later version.
##
## CDS Invenio is distributed in the hope that it will be useful, but
## WITHOUT ANY WARRANTY; without even the implied warranty of
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
## General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with CDS Invenio; if not, write to the Free Software Foundation, Inc.,
## 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA.
import
httplib
import
urllib
import
re
class
external_auth_nice
:
users
=
{}
name
=
""
def
__init__
(
self
):
#Initialize stuff here
pass
def
auth_user
(
self
,
username
,
password
):
#login user here
params
=
urllib
.
urlencode
({
'Username'
:
username
,
'Password'
:
password
})
headers
=
{
"Content-type"
:
"application/x-www-form-urlencoded"
,
"Accept"
:
"text/plain"
}
conn
=
httplib
.
HTTPSConnection
(
"winservices.web.cern.ch"
)
conn
.
request
(
"POST"
,
"/WinServices/Authentication/CDS/default.asp"
,
params
,
headers
)
response
=
conn
.
getresponse
()
data
=
response
.
read
()
conn
.
close
()
m
=
re
.
search
(
'<CCID>\d+</CCID>'
,
data
)
if
m
:
m
=
m
.
group
()
CCID
=
int
(
re
.
search
(
'\d+'
,
m
)
.
group
())
if
CCID
>
0
:
m
=
re
.
search
(
'<EMAIL>.*?</EMAIL>'
,
data
)
if
m
:
email
=
m
.
group
()
email
=
email
.
replace
(
'<EMAIL>'
,
''
)
email
=
email
.
replace
(
'</EMAIL>'
,
''
)
return
email
return
None
class
external_auth_template
:
def
__init__
(
self
):
#Initialize stuff here
pass
def
auth_user
(
self
,
username
,
password
):
#login user here
return
email
return
None
Event Timeline
Log In to Comment