Commit 64f7f958 authored by David Douard's avatar David Douard
Browse files

[entities] raise a ConfigurationError at registration time if no secret key is defined

parent 1c8ccd5573a4
......@@ -24,9 +24,16 @@ CONFENTRY = 'trustedauth-secret-key-file'
# make sure the secret key file is loaded on both sides of cw (repo
# and web)
def registration_callback(vreg):
secret = open(vreg.config.get(CONFENTRY, "")).read().strip()
secretfile = vreg.config.get(CONFENTRY, "").strip()
if not secretfile:
raise ConfigurationError("Configuration '%s' is missing or empty. "
"Please check tour configuration file!" % CONFENTRY)
try:
secret = open(secretfile).read().strip()
except IOError:
raise ConfigurationError("Cannot open secret key file. Check your configuration file!")
if not secret or len(secret) > 32:
raise ConfigurationError('secret key must me a string 0 < len(key) <= 32')
vreg.config._secret = secret.ljust(32, '#')
vreg.debug('loaded secret key')
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