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
88ca7348
Verified
Commit
88ca7348
authored
6 years ago
by
Tanner Prestegard
Browse files
Options
Downloads
Patches
Plain Diff
Add permissions and settings for priority instance
parent
dcc3ccbc
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
config/settings/container/production.py
+13
-0
13 additions, 0 deletions
config/settings/container/production.py
gracedb/api/permissions.py
+17
-0
17 additions, 0 deletions
gracedb/api/permissions.py
with
30 additions
and
0 deletions
config/settings/container/production.py
+
13
−
0
View file @
88ca7348
...
...
@@ -8,6 +8,19 @@ SEND_XMPP_ALERTS = True
SEND_PHONE_ALERTS
=
True
SEND_EMAIL_ALERTS
=
True
# Priority server?
PRIORITY_SERVER
=
False
is_priority_server
=
os
.
environ
.
get
(
'
DJANGO_PRIORITY_SERVER
'
,
None
)
if
(
isinstance
(
is_priority_server
,
str
)
and
is_priority_server
.
lower
()
in
[
'
true
'
,
'
t
'
]):
PRIORITY_SERVER
=
True
# If priority server, add custom permissions for API
if
PRIORITY_SERVER
:
default_perms
=
list
(
REST_FRAMEWORK
[
'
DEFAULT_PERMISSION_CLASSES
'
])
default_perms
=
[
'
api.permissions.IsPriorityUser
'
]
+
default_perms
REST_FRAMEWORK
[
'
DEFAULT_PERMISSION_CLASSES
'
]
=
tuple
(
default_perms
)
# Safety check on debug mode for production
if
(
DEBUG
==
True
):
raise
RuntimeError
(
"
Turn off debug mode for production
"
)
This diff is collapsed.
Click to expand it.
gracedb/api/permissions.py
0 → 100644
+
17
−
0
View file @
88ca7348
import
logging
from
django.conf
import
settings
from
rest_framework
import
permissions
# Set up logger
logger
=
logging
.
getLogger
(
__name__
)
class
IsPriorityUser
(
permissions
.
BasePermission
):
"""
Only allow users in the priority users group
"""
message
=
'
You are not authorized to use this API.
'
def
has_permission
(
self
,
request
,
view
):
return
request
.
user
.
groups
.
filter
(
name
=
settings
.
PRIORITY_USERS_GROUP
).
exists
()
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