Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GraceDB Server
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
Michael William Coughlin
GraceDB Server
Commits
2af4a52e
Commit
2af4a52e
authored
12 years ago
by
Branson Stephens
Browse files
Options
Downloads
Patches
Plain Diff
Added a second call to the django auth middleware after the gracedb LigoAuthMiddleware
parent
16d5d6f1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
gracedb/middleware/auth.py
+34
-30
34 additions, 30 deletions
gracedb/middleware/auth.py
settings/default.py
+8
-3
8 additions, 3 deletions
settings/default.py
with
42 additions
and
33 deletions
gracedb/middleware/auth.py
+
34
−
30
View file @
2af4a52e
...
...
@@ -19,38 +19,42 @@ class LigoAuthMiddleware:
ligouser
=
None
user
=
None
principal
=
request
.
META
.
get
(
'
REMOTE_USER
'
)
certdn
=
request
.
META
.
get
(
'
SSL_CLIENT_S_DN
'
)
issuer
=
request
.
META
.
get
(
'
SSL_CLIENT_I_DN
'
)
if
not
certdn
:
try
:
# mod_python is a little off...
# SSL info is in request._req
# Need to try/except because _req is
# not defined in WSGI request.
certdn
=
request
.
_req
.
ssl_var_lookup
(
'
SSL_CLIENT_S_DN
'
)
issuer
=
request
.
_req
.
ssl_var_lookup
(
'
SSL_CLIENT_I_DN
'
)
pass
except
:
pass
queryResult
=
[]
if
principal
:
# Kerberos.
if
(
request
.
user
):
# Scott's middleware has set the user aready using shib.
# Let's add some more attributes.
principal
=
request
.
user
.
username
request
.
user
.
name
=
nameFromPrincipal
(
principal
)
queryResult
=
User
.
objects
.
filter
(
principal
=
principal
)
elif
certdn
and
certdn
.
startswith
(
issuer
):
# proxy.
# Proxies can be signed by proxies.
# Each level of "proxification" causes the subject
# to have a '/CN=[0-9]+ appended to the signers subject.
# These must be removed to discover the original identity's
# subject DN.
issuer
=
proxyPattern
.
match
(
issuer
).
group
(
1
)
queryResult
=
User
.
objects
.
filter
(
dn
=
issuer
)
elif
certdn
:
# cert in browser.
queryResult
=
User
.
objects
.
filter
(
dn
=
certdn
)
else
:
# authenticate with certs
certdn
=
request
.
META
.
get
(
'
SSL_CLIENT_S_DN
'
)
issuer
=
request
.
META
.
get
(
'
SSL_CLIENT_I_DN
'
)
if
not
certdn
:
try
:
# mod_python is a little off...
# SSL info is in request._req
# Need to try/except because _req is
# not defined in WSGI request.
certdn
=
request
.
_req
.
ssl_var_lookup
(
'
SSL_CLIENT_S_DN
'
)
issuer
=
request
.
_req
.
ssl_var_lookup
(
'
SSL_CLIENT_I_DN
'
)
pass
except
:
pass
if
certdn
and
certdn
.
startswith
(
issuer
):
# proxy.
# Proxies can be signed by proxies.
# Each level of "proxification" causes the subject
# to have a '/CN=[0-9]+ appended to the signers subject.
# These must be removed to discover the original identity's
# subject DN.
issuer
=
proxyPattern
.
match
(
issuer
).
group
(
1
)
queryResult
=
User
.
objects
.
filter
(
dn
=
issuer
)
elif
certdn
:
# cert in browser.
queryResult
=
User
.
objects
.
filter
(
dn
=
certdn
)
if
queryResult
:
ligouser
=
queryResult
[
0
]
...
...
This diff is collapsed.
Click to expand it.
settings/default.py
+
8
−
3
View file @
2af4a52e
...
...
@@ -161,18 +161,23 @@ TEMPLATE_CONTEXT_PROCESSORS = (
)
AUTHENTICATION_BACKENDS
=
(
'
django.contrib.auth.backends.ModelBackend
'
,
'
gracedb.middleware.auth.LigoAuthBackend
'
,
'
ligodjangoauth.LigoShibbolethAuthBackend
'
,
'
django.contrib.auth.backends.ModelBackend
'
,
)
SHIB_AUTHENTICATION_SESSION_INITIATOR
=
'
https://moe.phys.uwm.edu/Shibboleth.sso/Login
'
MIDDLEWARE_CLASSES
=
[
'
middleware.accept.AcceptMiddleware
'
,
'
gracedb.middleware.auth.LigoAuthMiddleware
'
,
'
middleware.cli.CliExceptionMiddleware
'
,
'
django.middleware.common.CommonMiddleware
'
,
'
django.contrib.sessions.middleware.SessionMiddleware
'
,
'
django.contrib.auth.middleware.AuthenticationMiddleware
'
,
'
django.contrib.messages.middleware.MessageMiddleware
'
,
'
django.contrib.auth.middleware.AuthenticationMiddleware
'
,
'
ligodjangoauth.LigoShibbolethMiddleware
'
,
'
gracedb.middleware.auth.LigoAuthMiddleware
'
,
'
django.contrib.auth.middleware.AuthenticationMiddleware
'
,
]
ROOT_URLCONF
=
'
urls
'
...
...
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