Exemplo n.º 1
0
def GenerateDjangoKey(config):
    """Update a config with a random django key."""
    try:
        secret_key = config["AdminUI.django_secret_key"]
    except ConfigParser.NoOptionError:
        secret_key = "CHANGE_ME"  # This is the config file default.

    if not secret_key or secret_key.strip().upper() == "CHANGE_ME":
        key = utils.GeneratePassphrase(length=100)
        config.Set("AdminUI.django_secret_key", key)
    else:
        print "Not updating django_secret_key as it is already set."
Exemplo n.º 2
0
def GenerateCSRFKey(config):
    """Update a config with a random csrf key."""
    secret_key = config.Get("AdminUI.csrf_secret_key", None)
    if not secret_key:
        # TODO(user): Remove support for django_secret_key.
        secret_key = config.Get("AdminUI.django_secret_key", None)
        if secret_key:
            config.Set("AdminUI.csrf_secret_key", secret_key)

    if not secret_key:
        key = utils.GeneratePassphrase(length=100)
        config.Set("AdminUI.csrf_secret_key", key)
    else:
        print "Not updating csrf key as it is already set."