Create JWK formatted key on startup

This commit is contained in:
Evan Cordell 2016-04-27 12:10:03 -05:00 committed by Jimmy Zelinskie
parent 8595140f38
commit cf5f7aa476
2 changed files with 2 additions and 17 deletions

Binary file not shown.

19
boot.py
View file

@ -19,26 +19,11 @@ def create_quay_service_key(seconds_until_expiration):
expiration = timedelta(seconds=seconds_until_expiration)
private_key, service_key = generate_service_key('quay', datetime.now()+expiration)
approve_service_key(service_key.kid, None, ServiceKeyApprovalType.SUPERUSER)
private_key_file = {
'KeyID': service_key.kid,
'PrivateKey': {
'N': int(private_key._n),
'E': int(private_key._e),
'D': int(private_key._d),
'Primes': [int(private_key._p), int(private_key._q)],
'Precomputed': {
'Dp': None,
'Dq': None,
'Quinv': None,
'CRTValues': []
}
}
}
jwk = RSAKey(key=private_key).serialize(private=True)
with open('/conf/quay.jwk', mode='w') as f:
f.truncate(0)
f.write(json.dumps(private_key_file))
f.write(json.dumps(jwk))
def create_jwtproxy_conf():