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
f5ec0cea
Commit
f5ec0cea
authored
6 years ago
by
Tanner Prestegard
Committed by
GraceDB
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Start moving auth-based decorators to ligoauth app
parent
96942f76
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gracedb/ligoauth/decorators.py
+27
-0
27 additions, 0 deletions
gracedb/ligoauth/decorators.py
with
27 additions
and
0 deletions
gracedb/ligoauth/decorators.py
0 → 100644
+
27
−
0
View file @
f5ec0cea
from
django.conf
import
settings
from
django.contrib.auth
import
REDIRECT_FIELD_NAME
from
django.contrib.auth.decorators
import
user_passes_test
from
django.core.exceptions
import
PermissionDenied
import
logging
logger
=
logging
.
getLogger
(
__name__
)
def
group_required
(
group_name
,
login_url
=
None
,
raise_exception
=
False
):
def
check_groups
(
user
):
in_group
=
user
.
groups
.
filter
(
name
=
group_name
).
exists
()
if
in_group
:
return
True
if
raise_exception
:
raise
PermissionDenied
return
False
return
user_passes_test
(
check_groups
,
login_url
=
login_url
)
def
internal_user_required
(
function
=
None
,
raise_exception
=
True
,
**
kwargs
):
actual_decorator
=
group_required
(
settings
.
LVC_GROUP
,
raise_exception
=
raise_exception
,
**
kwargs
)
if
function
:
return
actual_decorator
(
function
)
return
actual_decorator
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