Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
G
gracedb
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
99
Issues
99
List
Boards
Labels
Service Desk
Milestones
Iterations
Merge Requests
1
Merge Requests
1
Requirements
Requirements
List
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Test Cases
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issue
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lscsoft
gracedb
Commits
b099f6e3
Commit
b099f6e3
authored
Sep 17, 2020
by
Alexander Pace
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
adding asimov account and cert
parent
3036aeea
Pipeline
#155910
passed with stages
in 18 minutes and 28 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
0 deletions
+68
-0
gracedb/ligoauth/migrations/0069_setup_asimov.py
gracedb/ligoauth/migrations/0069_setup_asimov.py
+68
-0
No files found.
gracedb/ligoauth/migrations/0069_setup_asimov.py
0 → 100644
View file @
b099f6e3
# Generated by Django 2.2.10 on 2020-07-01 19:40
from
django.db
import
migrations
,
models
from
django.conf
import
settings
ROBOTS
=
[
{
'username'
:
'asimov'
,
'first_name'
:
''
,
'last_name'
:
'Daniel Williams'
,
# Note that the last_name acts as a display
'email'
:
'daniel.williams@ligo.org'
,
'dns'
:
[
"/DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=git.ligo.org/CN=asimov/CN=Daniel Williams/CN=UID:daniel.williams.robot"
,
]
},
]
def
create_robots
(
apps
,
schema_editor
):
User
=
apps
.
get_model
(
'auth'
,
'User'
)
X509Cert
=
apps
.
get_model
(
'ligoauth'
,
'X509Cert'
)
AuthGroup
=
apps
.
get_model
(
'ligoauth'
,
'AuthGroup'
)
lvc_group
=
AuthGroup
.
objects
.
get
(
name
=
settings
.
LVC_GROUP
)
robot_group
=
AuthGroup
.
objects
.
get
(
name
=
'robot_accounts'
)
for
entry
in
ROBOTS
:
user
,
created
=
User
.
objects
.
get_or_create
(
username
=
entry
[
'username'
])
if
created
:
user
.
first_name
=
entry
[
'first_name'
]
user
.
last_name
=
entry
[
'last_name'
]
user
.
email
=
entry
[
'email'
]
user
.
is_active
=
True
user
.
is_staff
=
False
user
.
is_superuser
=
False
user
.
save
()
# Create the cert objects and link them to our user.
for
dn
in
entry
[
'dns'
]:
cert
,
created
=
X509Cert
.
objects
.
get_or_create
(
subject
=
dn
,
user
=
user
)
# Add our user to the LVC group. This permission is required to
# do most things, but may *NOT* always be appropriate. It may
# also be necessary to give the robotic user permission to populate
# a particular pipeline.
lvc_group
.
user_set
.
add
(
user
)
# Add user to robot accounts
robot_group
.
user_set
.
add
(
user
)
def
delete_robots
(
apps
,
schema_editor
):
User
=
apps
.
get_model
(
'auth'
,
'User'
)
X509Cert
=
apps
.
get_model
(
'ligoauth'
,
'X509Cert'
)
for
entry
in
ROBOTS
:
for
dn
in
entry
[
'dns'
]:
X509Cert
.
objects
.
get
(
subject
=
dn
).
delete
()
User
.
objects
.
get
(
username
=
entry
[
'username'
]).
delete
()
class
Migration
(
migrations
.
Migration
):
dependencies
=
[
(
'ligoauth'
,
'0068_setup_swiftgrb'
),
]
operations
=
[
migrations
.
RunPython
(
create_robots
,
delete_robots
),
]
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment