Commit 3dae8d40 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by GraceDB

Update iDQ certificates

parent 63b0a9c0
# -*- 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
ACCOUNTS = {
'idq-wa': {
'old_cert': '/DC=org/DC=ligo/O=LIGO/OU=Services/CN=idqLHO/ldas-grid.ligo-wa.caltech.edu',
'new_cert': '/DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=ldas-grid.ligo-wa.caltech.edu/CN=idq-lho/CN=Reed Essick/CN=UID:reed.essick.robot',
},
'idq-la': {
'old_cert': '/DC=org/DC=ligo/O=LIGO/OU=Services/CN=idqLLO/ldas-grid.ligo-la.caltech.edu',
'new_cert': '/DC=org/DC=cilogon/C=US/O=LIGO/OU=Robots/CN=ldas-grid.ligo-la.caltech.edu/CN=idq-llo/CN=Reed Essick/CN=UID:reed.essick.robot',
},
}
def update_certs(apps, schema_editor):
User = apps.get_model('auth', 'User')
for user, certs in ACCOUNTS.iteritems():
# Get user
user = User.objects.get(username=user)
# Create new certificate
user.x509cert_set.create(subject=certs['new_cert'])
# Delete old certificate
old_cert = user.x509cert_set.get(subject=certs['old_cert'])
old_cert.delete()
def revert_certs(apps, schema_editor):
User = apps.get_model('auth', 'User')
X509Cert = apps.get_model('ligoauth', 'X509Cert')
for user, certs in ACCOUNTS.iteritems():
# Get user
user = User.objects.get(username=user)
# Create old certificate
user.x509cert_set.create(subject=certs['old_cert'])
# Delete new certificate
old_cert = user.x509cert_set.get(subject=certs['new_cert'])
old_cert.delete()
class Migration(migrations.Migration):
dependencies = [
('ligoauth', '0018_update_cds_llo_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