Commit c82be66c authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

Remove old dashboard X509 certificates

parent 46298d66
Pipeline #42791 passed with stage
in 5 minutes and 9 seconds
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-12-18 20:47
from __future__ import unicode_literals
from django.db import migrations
ACCOUNT = {
'username': 'nagios',
'old_certs': [
'/DC=org/DC=doegrids/OU=Services/CN=nagios/sentry.phys.uwm.edu',
'/DC=org/DC=ligo/O=LIGO/OU=Services/CN=nagios/sentry.phys.uwm.edu',
'/DC=org/DC=ligo/O=LIGO/OU=Services/CN=nagios/gracedb.cgca.uwm.edu',
'/DC=org/DC=ligo/O=LIGO/OU=Services/CN=nagios/dashboard.cgca.uwm.edu',
],
}
def remove_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'])
# Remove old certs
for subject in ACCOUNT['old_certs']:
cert = user.x509cert_set.get(subject=subject)
cert.delete()
def add_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'])
# Re-create old certs
for subject in ACCOUNT['old_certs']:
cert = user.x509cert_set.create(subject=subject)
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0019_update_idq_certs'),
]
operations = [
migrations.RunPython(remove_certs, add_certs),
]
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment