Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
cubicweb
cubes
trustedauth
Commits
5717efef00fc
Commit
64f7f958
authored
Jan 27, 2011
by
David Douard
Browse files
[entities] raise a ConfigurationError at registration time if no secret key is defined
parent
1c8ccd5573a4
Changes
1
Hide whitespace changes
Inline
Side-by-side
entities.py
View file @
5717efef
...
...
@@ -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'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment