Commit 63b0a9c0 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

Update certs for LLO CDS

parent 4ee31f4d
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2018-12-14 15:55
from __future__ import unicode_literals
from django.db import migrations
ACCOUNT_NAME = 'cds_llo'
NEW_CERT = '/DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=cds-outbound.ligo-la.caltech.edu/CN=exttrig/CN=Keith Thorne/CN=UID:keith.thorne.robot'
OLD_CERTS = [
'/DC=org/DC=ligo/O=LIGO/OU=Services/CN=exttrig/cds-outbound.ligo-la.caltech.edu',
]
def update_certs(apps, schema_editor):
User = apps.get_model('auth', 'User')
# Get user
user = User.objects.get(username=ACCOUNT_NAME)
# Create new certificate
user.x509cert_set.create(subject=NEW_CERT)
# Delete old certificates
for subj in OLD_CERTS:
old_cert = user.x509cert_set.get(subject=subj)
old_cert.delete()
def revert_certs(apps, schema_editor):
User = apps.get_model('auth', 'User')
X509Cert = apps.get_model('ligoauth', 'X509Cert')
# Delete new certificate
new_cert = X509Cert.objects.get(subject=NEW_CERT)
new_cert.delete()
# Get user
user = User.objects.get(username=ACCOUNT_NAME)
# Create old certificates
for subj in OLD_CERTS:
user.x509cert_set.create(subject=subj)
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0017_update_cds_lho_certs'),
]
operations = [
migrations.RunPython(update_certs, revert_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