~roadmr/canonical-identity-provider/charm-xenial-minideploy

« back to all changes in this revision

Viewing changes to templates/settings.py.j2

  • Committer: Tarmac
  • Author(s): Facundo Batista
  • Date: 2016-05-13 15:15:14 UTC
  • mfrom: (70.1.1 change-cryptography)
  • Revision ID: tarmac-20160513151514-l87xsdt6wt4tnnq2
[r=roadmr] Use new crypto functions to load the key.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
#--------------------------------------------------------------
2
2
# This file is managed by Juju; ANY CHANGES WILL BE OVERWRITTEN
3
3
#--------------------------------------------------------------
 
4
 
 
5
import base64
4
6
import os
5
7
 
6
 
from Crypto.PublicKey import RSA
7
 
 
8
8
os.environ['SSO_HOST_DIR'] = "{{ hostdir }}"
9
9
os.environ.setdefault('SSO_LOGS_DIR', "{{ log_dir }}")
10
10
os.environ.setdefault('SSO_ROOT_URL', "https://{{ hostname }}")
46
46
{% endif %}
47
47
COMBINE = {{ combine }}
48
48
{% if crypto_sso_privkey %}
49
 
import base64
 
49
# importing this here because it should happen in the project's context, not in the charm's one
 
50
from identityprovider import crypto
50
51
_crypto_sso_raw = base64.b64decode("{{ crypto_sso_privkey }}")
51
 
CRYPTO_SSO_PRIVKEY = RSA.importKey(_crypto_sso_raw)
 
52
CRYPTO_SSO_PRIVKEY = crypto.parse_private_key(_crypto_sso_raw)
52
53
{% endif %}
53
54
DATABASES['default']['USER'] = os.getenv('DB_USER', "{{ db_user }}")
54
55
DATABASES['default']['PASSWORD'] = os.getenv('DB_PASSWORD', "{{ db_password }}")