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
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
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
IGWN Computing and Software
GraceDB
GraceDB Server
Commits
a3486e79
Commit
a3486e79
authored
6 years ago
by
Tanner Prestegard
Committed by
GraceDB
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add account and cert for Fermi GBM follow-up
parent
0c815890
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Pipeline
#55030
passed
6 years ago
Stage: branch
Stage: latest
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gracedb/ligoauth/migrations/0028_create_gbm_followup_account_and_certs.py
+61
-0
61 additions, 0 deletions
.../migrations/0028_create_gbm_followup_account_and_certs.py
with
61 additions
and
0 deletions
gracedb/ligoauth/migrations/0028_create_gbm_followup_account_and_certs.py
0 → 100644
+
61
−
0
View file @
a3486e79
# -*- coding: utf-8 -*-
# Generated by Django 1.11.18 on 2019-03-27 17:12
from
__future__
import
unicode_literals
from
django.conf
import
settings
from
django.db
import
migrations
ACCOUNT
=
{
'
username
'
:
'
fermi-gbm-follow-up
'
,
'
email
'
:
'
tyson.littenberg@ligo.org
'
,
'
first_name
'
:
''
,
'
last_name
'
:
'
Fermi-GBM follow-up
'
,
}
CERTS
=
[
'
/DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=hippo.nsstc.uah.edu/CN=Fermi-GBM-follow-up/CN=Tyson Littenberg/CN=UID:tyson.littenberg.robot
'
,
]
def
create_account_and_certs
(
apps
,
schema_editor
):
RobotUser
=
apps
.
get_model
(
'
ligoauth
'
,
'
RobotUser
'
)
X509Cert
=
apps
.
get_model
(
'
ligoauth
'
,
'
X509Cert
'
)
Group
=
apps
.
get_model
(
'
auth
'
,
'
Group
'
)
# Create user
user
=
RobotUser
.
objects
.
create
(
**
ACCOUNT
)
# Add user to LVC group
group
=
Group
.
objects
.
get
(
name
=
settings
.
LVC_GROUP
)
group
.
user_set
.
add
(
user
)
# Create X509 certificates
for
subject
in
CERTS
:
user
.
x509cert_set
.
create
(
subject
=
subject
)
def
delete_account_and_certs
(
apps
,
schema_editor
):
RobotUser
=
apps
.
get_model
(
'
ligoauth
'
,
'
RobotUser
'
)
X509Cert
=
apps
.
get_model
(
'
ligoauth
'
,
'
X509Cert
'
)
# Get user
user
=
RobotUser
.
objects
.
get
(
username
=
ACCOUNT
[
'
username
'
])
# Delete certs
for
cert
in
user
.
x509cert_set
.
filter
(
subject__in
=
CERTS
):
cert
.
delete
()
# Delete full User object
user
.
user_ptr
.
delete
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'
ligoauth
'
,
'
0027_add_olib_cert
'
),
]
operations
=
[
migrations
.
RunPython
(
create_account_and_certs
,
delete_account_and_certs
),
]
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