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
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
7 deletions
+12
-7
django_cas/__init__.py
+0
-0
django_cas/middleware.py
+11
-6
django_cas/views.py
+1
-1
No files found.
django_cas/__init__.py
View file @
e36a262b
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,16 +17,21 @@ class CASMiddleware(object):
return
None
else
:
admin_path
=
[
'django'
,
'contrib'
,
'admin'
,
'views'
]
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
()})
...
...
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
:
...
...
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