Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
django-cas
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
OpenEdx
django-cas
Commits
e36a262b
Commit
e36a262b
authored
Dec 19, 2007
by
Chris Green
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
making code work with SVN 12/19/07
parent
f1e94819
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
14 deletions
+16
-14
django_cas/__init__.py
+1
-2
django_cas/middleware.py
+13
-9
django_cas/views.py
+2
-3
No files found.
django_cas/__init__.py
View file @
e36a262b
...
...
@@ -80,4 +80,4 @@ def verify(ticket, service):
username
=
page
.
readline
()
.
strip
()
if
verified
==
'yes'
:
return
username
return
None
\ No newline at end of file
return
None
django_cas/middleware.py
View file @
e36a262b
...
...
@@ -4,10 +4,10 @@ from django.conf import settings
class
CASMiddleware
(
object
):
def
process_request
(
self
,
request
):
error
=
"
The Django CAS middleware requires authentication "
"middleware to be installed. Edit your MIDDLEWARE_CLASSES "
"setting to insert 'django.contrib.auth.middleware."
"AuthenticationMiddleware'.
"
error
=
"
""The Django CAS middleware requires authentication
middleware to be installed. Edit your MIDDLEWARE_CLASSES
setting to insert 'django.contrib.auth.middleware.
AuthenticationMiddleware'.""
"
assert
hasattr
(
request
,
'user'
),
error
def
process_view
(
self
,
request
,
view_func
,
view_args
,
view_kwargs
):
...
...
@@ -17,17 +17,22 @@ class CASMiddleware(object):
return
None
else
:
admin_path
=
[
'django'
,
'contrib'
,
'admin'
,
'views'
]
view_file
=
view_func
.
func_code
.
co_filename
try
:
view_file
=
view_func
.
func_code
.
co_filename
except
AttributeError
:
# if we get a protected decororator that abstracts this away into something like _CheckLogin
view_file
=
view_func
.
view_func
.
func_code
.
co_filename
view_path
=
path
.
split
(
view_file
)[
0
]
.
split
(
path
.
sep
)[
-
4
:]
if
view_path
!=
admin_path
:
return
None
if
request
.
user
.
is_authenticated
():
if
request
.
user
.
is_staff
:
return
None
else
:
error
=
"<h1>Forbidden</h1>"
"<p>You do not have staff privileges.</p>"
error
=
"<h1>Forbidden</h1><p>You do not have staff privileges.</p>"
return
HttpResponseForbidden
(
error
)
field
,
url
=
settings
.
CAS_REDIRECT_FIELD_NAME
,
settings
.
CAS_LOGIN_URL
params
=
urlencode
({
field
:
request
.
get_full_path
()})
return
HttpResponseRedirect
(
url
+
'?'
+
params
)
\ No newline at end of file
return
HttpResponseRedirect
(
url
+
'?'
+
params
)
django_cas/views.py
View file @
e36a262b
from
django.http
import
HttpResponseRedirect
,
HttpResponseForbidden
,
urlencode
from
django.conf
import
settings
from
django_cas
import
redirect_url
,
service_url
from
django_cas
import
redirect_url
,
service_url
,
login_url
def
login
(
request
,
next_page
=
None
):
if
not
next_page
:
...
...
@@ -34,4 +34,4 @@ def logout(request, next_page=None):
logout
(
request
)
if
not
next_page
:
next_page
=
redirect_url
(
request
)
return
HttpResponseRedirect
(
next_page
)
\ No newline at end of file
return
HttpResponseRedirect
(
next_page
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment