annotate MoinMoin/support/passlib/apps.py @ 6130:7f0616feeae9

upgrade passlib to 1.7.1, update CHANGES
author Thomas Waldmann <tw AT waldmann-edv DOT de>
date Tue, 11 Apr 2017 22:53:58 +0200
parents 86a41c2bedec
children
rev   line source
5919
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
1 """passlib.apps"""
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
2 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
3 # imports
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
4 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
5 # core
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
6 import logging; log = logging.getLogger(__name__)
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
7 from itertools import chain
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
8 # site
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
9 # pkg
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
10 from passlib import hash
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
11 from passlib.context import LazyCryptContext
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
12 from passlib.utils import sys_bits
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
13 # local
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
14 __all__ = [
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
15 'custom_app_context',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
16 'django_context',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
17 'ldap_context', 'ldap_nocrypt_context',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
18 'mysql_context', 'mysql4_context', 'mysql3_context',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
19 'phpass_context',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
20 'phpbb3_context',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
21 'postgres_context',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
22 ]
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
23
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
24 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
25 # master containing all identifiable hashes
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
26 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
27 def _load_master_config():
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
28 from passlib.registry import list_crypt_handlers
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
29
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
30 # get master list
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
31 schemes = list_crypt_handlers()
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
32
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
33 # exclude the ones we know have ambiguous or greedy identify() methods.
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
34 excluded = [
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
35 # frequently confused for eachother
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
36 'bigcrypt',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
37 'crypt16',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
38
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
39 # no good identifiers
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
40 'cisco_pix',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
41 'cisco_type7',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
42 'htdigest',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
43 'mysql323',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
44 'oracle10',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
45
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
46 # all have same size
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
47 'lmhash',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
48 'msdcc',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
49 'msdcc2',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
50 'nthash',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
51
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
52 # plaintext handlers
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
53 'plaintext',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
54 'ldap_plaintext',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
55
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
56 # disabled handlers
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
57 'django_disabled',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
58 'unix_disabled',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
59 'unix_fallback',
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
60 ]
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
61 for name in excluded:
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
62 schemes.remove(name)
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
63
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
64 # return config
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
65 return dict(schemes=schemes, default="sha256_crypt")
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
66 master_context = LazyCryptContext(onload=_load_master_config)
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
67
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
68 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
69 # for quickly bootstrapping new custom applications
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
70 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
71 custom_app_context = LazyCryptContext(
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
72 # choose some reasonbly strong schemes
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
73 schemes=["sha512_crypt", "sha256_crypt"],
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
74
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
75 # set some useful global options
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
76 default="sha256_crypt" if sys_bits < 64 else "sha512_crypt",
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
77
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
78 # set a good starting point for rounds selection
6096
86a41c2bedec upgrade passlib from 1.6.2 to 1.6.5
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 6008
diff changeset
79 sha512_crypt__min_rounds = 535000,
86a41c2bedec upgrade passlib from 1.6.2 to 1.6.5
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 6008
diff changeset
80 sha256_crypt__min_rounds = 535000,
5919
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
81
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
82 # if the admin user category is selected, make a much stronger hash,
6096
86a41c2bedec upgrade passlib from 1.6.2 to 1.6.5
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 6008
diff changeset
83 admin__sha512_crypt__min_rounds = 1024000,
86a41c2bedec upgrade passlib from 1.6.2 to 1.6.5
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 6008
diff changeset
84 admin__sha256_crypt__min_rounds = 1024000,
5919
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
85 )
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
86
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
87 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
88 # django
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
89 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
90 _django10_schemes = [
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
91 "django_salted_sha1", "django_salted_md5", "django_des_crypt",
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
92 "hex_md5", "django_disabled",
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
93 ]
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
94
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
95 django10_context = LazyCryptContext(
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
96 schemes=_django10_schemes,
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
97 default="django_salted_sha1",
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
98 deprecated=["hex_md5"],
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
99 )
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
100
6008
d72a5e95c7c0 upgrade bundled passlib to 1.6.2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5919
diff changeset
101 _django14_schemes = ["django_pbkdf2_sha256", "django_pbkdf2_sha1",
d72a5e95c7c0 upgrade bundled passlib to 1.6.2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5919
diff changeset
102 "django_bcrypt"] + _django10_schemes
5919
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
103 django14_context = LazyCryptContext(
6008
d72a5e95c7c0 upgrade bundled passlib to 1.6.2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5919
diff changeset
104 schemes=_django14_schemes,
d72a5e95c7c0 upgrade bundled passlib to 1.6.2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5919
diff changeset
105 deprecated=_django10_schemes,
d72a5e95c7c0 upgrade bundled passlib to 1.6.2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5919
diff changeset
106 )
d72a5e95c7c0 upgrade bundled passlib to 1.6.2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5919
diff changeset
107
d72a5e95c7c0 upgrade bundled passlib to 1.6.2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5919
diff changeset
108 _django16_schemes = _django14_schemes[:]
d72a5e95c7c0 upgrade bundled passlib to 1.6.2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5919
diff changeset
109 _django16_schemes.insert(1, "django_bcrypt_sha256")
d72a5e95c7c0 upgrade bundled passlib to 1.6.2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5919
diff changeset
110 django16_context = LazyCryptContext(
d72a5e95c7c0 upgrade bundled passlib to 1.6.2
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 5919
diff changeset
111 schemes=_django16_schemes,
5919
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
112 deprecated=_django10_schemes,
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
113 )
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
114
6130
7f0616feeae9 upgrade passlib to 1.7.1, update CHANGES
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 6096
diff changeset
115 django110_context = LazyCryptContext(
7f0616feeae9 upgrade passlib to 1.7.1, update CHANGES
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 6096
diff changeset
116 schemes=["django_pbkdf2_sha256", "django_pbkdf2_sha1",
7f0616feeae9 upgrade passlib to 1.7.1, update CHANGES
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 6096
diff changeset
117 "django_argon2", "django_bcrypt", "django_bcrypt_sha256",
7f0616feeae9 upgrade passlib to 1.7.1, update CHANGES
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 6096
diff changeset
118 "django_disabled"],
7f0616feeae9 upgrade passlib to 1.7.1, update CHANGES
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 6096
diff changeset
119 )
7f0616feeae9 upgrade passlib to 1.7.1, update CHANGES
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 6096
diff changeset
120
5919
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
121 # this will always point to latest version
6130
7f0616feeae9 upgrade passlib to 1.7.1, update CHANGES
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 6096
diff changeset
122 django_context = django110_context
5919
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
123
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
124 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
125 # ldap
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
126 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
127 std_ldap_schemes = ["ldap_salted_sha1", "ldap_salted_md5",
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
128 "ldap_sha1", "ldap_md5",
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
129 "ldap_plaintext" ]
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
130
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
131 # create context with all std ldap schemes EXCEPT crypt
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
132 ldap_nocrypt_context = LazyCryptContext(std_ldap_schemes)
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
133
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
134 # create context with all possible std ldap + ldap crypt schemes
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
135 def _iter_ldap_crypt_schemes():
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
136 from passlib.utils import unix_crypt_schemes
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
137 return ('ldap_' + name for name in unix_crypt_schemes)
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
138
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
139 def _iter_ldap_schemes():
6096
86a41c2bedec upgrade passlib from 1.6.2 to 1.6.5
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 6008
diff changeset
140 """helper which iterates over supported std ldap schemes"""
5919
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
141 return chain(std_ldap_schemes, _iter_ldap_crypt_schemes())
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
142 ldap_context = LazyCryptContext(_iter_ldap_schemes())
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
143
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
144 ### create context with all std ldap schemes + crypt schemes for localhost
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
145 ##def _iter_host_ldap_schemes():
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
146 ## "helper which iterates over supported std ldap schemes"
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
147 ## from passlib.handlers.ldap_digests import get_host_ldap_crypt_schemes
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
148 ## return chain(std_ldap_schemes, get_host_ldap_crypt_schemes())
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
149 ##ldap_host_context = LazyCryptContext(_iter_host_ldap_schemes())
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
150
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
151 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
152 # mysql
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
153 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
154 mysql3_context = LazyCryptContext(["mysql323"])
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
155 mysql4_context = LazyCryptContext(["mysql41", "mysql323"], deprecated="mysql323")
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
156 mysql_context = mysql4_context # tracks latest mysql version supported
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
157
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
158 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
159 # postgres
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
160 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
161 postgres_context = LazyCryptContext(["postgres_md5"])
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
162
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
163 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
164 # phpass & variants
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
165 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
166 def _create_phpass_policy(**kwds):
6096
86a41c2bedec upgrade passlib from 1.6.2 to 1.6.5
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents: 6008
diff changeset
167 """helper to choose default alg based on bcrypt availability"""
5919
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
168 kwds['default'] = 'bcrypt' if hash.bcrypt.has_backend() else 'phpass'
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
169 return kwds
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
170
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
171 phpass_context = LazyCryptContext(
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
172 schemes=["bcrypt", "phpass", "bsdi_crypt"],
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
173 onload=_create_phpass_policy,
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
174 )
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
175
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
176 phpbb3_context = LazyCryptContext(["phpass"], phpass__ident="H")
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
177
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
178 # TODO: support the drupal phpass variants (see phpass homepage)
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
179
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
180 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
181 # roundup
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
182 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
183
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
184 _std_roundup_schemes = [ "ldap_hex_sha1", "ldap_hex_md5", "ldap_des_crypt", "roundup_plaintext" ]
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
185 roundup10_context = LazyCryptContext(_std_roundup_schemes)
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
186
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
187 # NOTE: 'roundup15' really applies to roundup 1.4.17+
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
188 roundup_context = roundup15_context = LazyCryptContext(
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
189 schemes=_std_roundup_schemes + [ "ldap_pbkdf2_sha1" ],
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
190 deprecated=_std_roundup_schemes,
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
191 default = "ldap_pbkdf2_sha1",
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
192 ldap_pbkdf2_sha1__default_rounds = 10000,
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
193 )
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
194
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
195 #=============================================================================
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
196 # eof
efd7c0be3339 added passlib 1.6.1 to MoinMoin/support/
Thomas Waldmann <tw AT waldmann-edv DOT de>
parents:
diff changeset
197 #=============================================================================