Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Helios Server
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
TO
Helios Server
Commits
efae9b4d
Commit
efae9b4d
authored
14 years ago
by
Ben Adida
Browse files
Options
Downloads
Patches
Plain Diff
reenabled older version of CAS auth, since SAML is taking time to work
parent
259cea63
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
auth/auth_systems/cas.py
+40
-5
40 additions, 5 deletions
auth/auth_systems/cas.py
with
40 additions
and
5 deletions
auth/auth_systems/cas.py
+
40
−
5
View file @
efae9b4d
...
...
@@ -57,26 +57,32 @@ def get_saml_info(ticket):
"""
Using SAML, get all of the information needed
"""
import
logging
saml_request
=
"""
<?xml version=
'
1.0
'
encoding=
'
UTF-8
'
?>
<soap-env:Envelope
xmlns:soap-env=
'
http://schemas.xmlsoap.org/soap/envelope/
'
>
<soap-env:Header />
<soap-env:Body>
<samlp:Request xmlns:samlp=
"
urn:oasis:names:tc:SAML:1.0:protocol
"
MajorVersion=
"
1
"
MinorVersion=
"
1
"
RequestID=
"
%s
"
IssueInstant=
"
%s
"
>
IssueInstant=
"
%s
Z
"
>
<samlp:AssertionArtifact>%s</samlp:AssertionArtifact>
</samlp:Request>
</soap-env:Body>
</soap-env:Envelope>
"""
%
(
uuid
.
uuid1
(),
datetime
.
datetime
.
utcnow
(),
ticket
)
"""
%
(
uuid
.
uuid1
(),
datetime
.
datetime
.
utcnow
()
.
isoformat
()
,
ticket
)
url
=
CAS_SAML_VALIDATE_URL
%
urllib
.
quote
(
_get_service_url
())
# by virtue of having a body, this is a POST
req
=
urllib2
.
Request
(
url
,
saml_request
)
raw_response
=
urllib2
.
urlopen
(
req
).
read
()
logging
.
info
(
"
RESP:
\n
%s
\n\n
"
%
raw_response
)
response
=
ElementTree
.
fromstring
(
raw_response
)
# ugly path down the tree of attributes
...
...
@@ -137,6 +143,33 @@ def get_user_info(user_id):
else
:
return
None
def
get_user_info_special
(
ticket
):
# fetch the information from the CAS server
val_url
=
CAS_URL
+
"
validate
"
+
\
'
?service=
'
+
urllib
.
quote
(
_get_service_url
())
+
\
'
&ticket=
'
+
urllib
.
quote
(
ticket
)
r
=
urllib
.
urlopen
(
val_url
).
readlines
()
# returns 2 lines
# success
if
len
(
r
)
==
2
and
re
.
match
(
"
yes
"
,
r
[
0
])
!=
None
:
netid
=
r
[
1
].
strip
()
category
=
get_user_category
(
netid
)
try
:
user_info
=
get_user_info
(
netid
)
except
:
user_info
=
None
if
user_info
:
info
=
{
'
name
'
:
user_info
[
'
name
'
],
'
category
'
:
category
}
else
:
info
=
{
'
name
'
:
netid
,
'
category
'
:
category
}
return
{
'
user_id
'
:
netid
,
'
name
'
:
info
[
'
name
'
],
'
info
'
:
info
,
'
token
'
:
None
}
else
:
return
None
def
get_user_info_after_auth
(
request
):
ticket
=
request
.
GET
.
get
(
'
ticket
'
,
None
)
...
...
@@ -144,7 +177,9 @@ def get_user_info_after_auth(request):
if
not
ticket
:
return
None
user_info
=
get_saml_info
(
ticket
)
#user_info = get_saml_info(ticket)
user_info
=
get_user_info_special
(
ticket
)
user_info
[
'
type
'
]
=
'
cas
'
return
user_info
...
...
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