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 Coughlin
GraceDB Server
Commits
5e13c971
Commit
5e13c971
authored
6 years ago
by
Tanner Prestegard
Committed by
GraceDB
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
move LigoAuthentication from events.api.views to events.api.backends
parent
d63d4ddf
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
config/settings/base.py
+3
-0
3 additions, 0 deletions
config/settings/base.py
gracedb/events/api/backends.py
+28
-0
28 additions, 0 deletions
gracedb/events/api/backends.py
gracedb/events/api/views.py
+1
-22
1 addition, 22 deletions
gracedb/events/api/views.py
with
32 additions
and
22 deletions
config/settings/base.py
+
3
−
0
View file @
5e13c971
...
...
@@ -309,6 +309,9 @@ REST_FRAMEWORK = {
'
event_creation
'
:
'
1/second
'
,
'
annotation
'
:
'
10/second
'
,
},
'
DEFAULT_AUTHENTICATION_CLASSES
'
:
(
'
events.api.backends.LigoAuthentication
'
,
),
}
# Location of packages installed by bower
...
...
This diff is collapsed.
Click to expand it.
gracedb/events/api/backends.py
0 → 100644
+
28
−
0
View file @
5e13c971
from
django.contrib.auth
import
get_user_model
from
django.utils.translation
import
ugettext_lazy
as
_
from
rest_framework
import
authentication
,
exceptions
UserModel
=
get_user_model
()
# We do not want to handle authentication here because it has already
# been taken care of by Apache/Shib or Apache/mod_ssl. Moreover the
# auth middleware has already added a user to the request object. To
# play well with the django rest framework, we need to pretend like we
# authenticated the user. Remember that the request object here is a
# *wrapped* version of the Django request, so we have to dig inside it
# for the user.
class
LigoAuthentication
(
authentication
.
BaseAuthentication
):
def
authenticate
(
self
,
request
):
user
=
None
try
:
user
=
request
.
_request
.
user
except
:
pass
if
isinstance
(
user
,
UserModel
):
return
(
user
,
None
)
else
:
raise
exceptions
.
AuthenticationFailed
(
_
(
'
Bad user
'
))
This diff is collapsed.
Click to expand it.
gracedb/events/api/views.py
+
1
−
22
View file @
5e13c971
...
...
@@ -28,6 +28,7 @@ from ..forms import CreateEventForm
from
..permission_utils
import
user_has_perm
,
filter_events_for_user
,
\
is_external
,
check_external_file_access
from
.backends
import
LigoAuthentication
from
.throttles
import
EventCreationThrottle
,
AnnotationThrottle
from
core.vfile
import
VersionedFile
...
...
@@ -83,28 +84,6 @@ import StringIO
use_in
(
LIGOLWContentHandler
)
#
# We do not want to handle authentication here because it has already
# been taken care of by Apache/Shib or Apache/mod_ssl. Moreover the
# auth middleware has already added a user to the request object. To
# play well with the django rest framework, we need to pretend like we
# authenticated the user. Remember that the request object here is a
# *wrapped* version of the Django request, so we have to dig inside it
# for the user.
#
class
LigoAuthentication
(
authentication
.
BaseAuthentication
):
def
authenticate
(
self
,
request
):
user
=
None
try
:
user
=
request
.
_request
.
user
except
:
pass
if
isinstance
(
user
,
User
):
return
(
user
,
None
)
else
:
raise
exceptions
.
AuthenticationFailed
(
"
Bad user
"
)
#
# A custom permission class for the EventDetail view.
#
...
...
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