|
|
@ -13,17 +13,16 @@ def crypt_context_settings_to_string(settings, prefix='passlib.'): |
|
|
|
:rtype: (str) config string in INI format for CryptContext.load() |
|
|
|
:rtype: (str) config string in INI format for CryptContext.load() |
|
|
|
|
|
|
|
|
|
|
|
This looks at first like a dump hack, but the parsing of all possible |
|
|
|
This looks at first like a dump hack, but the parsing of all possible |
|
|
|
context settings is quite a task. Since passlib has a context parser |
|
|
|
context settings is quite a task. Since passlib has a context parser |
|
|
|
included, this seems the most reliable way to do it. |
|
|
|
included, this seems the most reliable way to do it. |
|
|
|
''' |
|
|
|
''' |
|
|
|
as_list_keys = {'schemes', 'deprecated'} |
|
|
|
|
|
|
|
config_lines = ['[passlib]'] |
|
|
|
config_lines = ['[passlib]'] |
|
|
|
for ini_key, value in settings.items(): |
|
|
|
for ini_key, value in settings.items(): |
|
|
|
if ini_key.startswith(prefix): |
|
|
|
if ini_key.startswith(prefix): |
|
|
|
context_key = ini_key.replace(prefix, '') |
|
|
|
context_key = ini_key.replace(prefix, '') |
|
|
|
# the pyramid .ini format is different on lists |
|
|
|
# the pyramid .ini format is different on lists |
|
|
|
# than the .ini format used by passlib. |
|
|
|
# than the .ini format used by passlib. |
|
|
|
if context_key in as_list_keys and ',' not in value: |
|
|
|
if context_key in {'schemes', 'deprecated'} and ',' not in value: |
|
|
|
value = ','.join(aslist(value)) |
|
|
|
value = ','.join(aslist(value)) |
|
|
|
config_lines.append(f'{context_key} = {value}') |
|
|
|
config_lines.append(f'{context_key} = {value}') |
|
|
|
return '\n'.join(config_lines) |
|
|
|
return '\n'.join(config_lines) |
|
|
@ -32,7 +31,7 @@ def crypt_context_settings_to_string(settings, prefix='passlib.'): |
|
|
|
def includeme(config): |
|
|
|
def includeme(config): |
|
|
|
''' initializing authentication, authorization and password hash settings |
|
|
|
''' initializing authentication, authorization and password hash settings |
|
|
|
|
|
|
|
|
|
|
|
Activate this setup using ``config.include('ordr2.security')``. |
|
|
|
Activate this setup using ``config.include('ordr.security')``. |
|
|
|
''' |
|
|
|
''' |
|
|
|
settings = config.get_settings() |
|
|
|
settings = config.get_settings() |
|
|
|
|
|
|
|
|
|
|
|