passlib 1.9.5__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. passlib/__init__.py +3 -0
  2. passlib/_data/wordsets/bip39.txt +2049 -0
  3. passlib/_data/wordsets/eff_long.txt +7776 -0
  4. passlib/_data/wordsets/eff_prefixed.txt +1296 -0
  5. passlib/_data/wordsets/eff_short.txt +1296 -0
  6. passlib/_logging.py +3 -0
  7. passlib/_protocols.py +33 -0
  8. passlib/apache.py +1106 -0
  9. passlib/apps.py +215 -0
  10. passlib/context.py +1944 -0
  11. passlib/crypto/__init__.py +1 -0
  12. passlib/crypto/_blowfish/__init__.py +153 -0
  13. passlib/crypto/_blowfish/_gen_files.py +238 -0
  14. passlib/crypto/_blowfish/base.py +1212 -0
  15. passlib/crypto/_blowfish/unrolled.py +1664 -0
  16. passlib/crypto/_md4.py +229 -0
  17. passlib/crypto/des.py +2250 -0
  18. passlib/crypto/digest.py +760 -0
  19. passlib/crypto/scrypt/__init__.py +273 -0
  20. passlib/crypto/scrypt/_builtin.py +220 -0
  21. passlib/crypto/scrypt/_gen_files.py +142 -0
  22. passlib/crypto/scrypt/_salsa.py +180 -0
  23. passlib/exc.py +409 -0
  24. passlib/ext/__init__.py +1 -0
  25. passlib/ext/django/__init__.py +6 -0
  26. passlib/ext/django/models.py +21 -0
  27. passlib/ext/django/utils.py +1181 -0
  28. passlib/handlers/__init__.py +1 -0
  29. passlib/handlers/argon2.py +999 -0
  30. passlib/handlers/bcrypt.py +996 -0
  31. passlib/handlers/cisco.py +396 -0
  32. passlib/handlers/des_crypt.py +504 -0
  33. passlib/handlers/digests.py +149 -0
  34. passlib/handlers/django.py +510 -0
  35. passlib/handlers/fshp.py +185 -0
  36. passlib/handlers/ldap_digests.py +356 -0
  37. passlib/handlers/md5_crypt.py +286 -0
  38. passlib/handlers/misc.py +201 -0
  39. passlib/handlers/mssql.py +217 -0
  40. passlib/handlers/mysql.py +92 -0
  41. passlib/handlers/oracle.py +137 -0
  42. passlib/handlers/pbkdf2.py +454 -0
  43. passlib/handlers/phpass.py +110 -0
  44. passlib/handlers/postgres.py +34 -0
  45. passlib/handlers/roundup.py +18 -0
  46. passlib/handlers/scram.py +532 -0
  47. passlib/handlers/scrypt.py +357 -0
  48. passlib/handlers/sha1_crypt.py +121 -0
  49. passlib/handlers/sha2_crypt.py +562 -0
  50. passlib/handlers/sun_md5_crypt.py +334 -0
  51. passlib/handlers/windows.py +299 -0
  52. passlib/hash.py +106 -0
  53. passlib/hosts.py +85 -0
  54. passlib/ifc.py +307 -0
  55. passlib/pwd.py +709 -0
  56. passlib/registry.py +547 -0
  57. passlib/totp.py +1852 -0
  58. passlib/utils/__init__.py +901 -0
  59. passlib/utils/binary.py +852 -0
  60. passlib/utils/compat/__init__.py +141 -0
  61. passlib/utils/decor.py +220 -0
  62. passlib/utils/des.py +31 -0
  63. passlib/utils/handlers.py +2616 -0
  64. passlib/utils/md4.py +25 -0
  65. passlib/utils/pbkdf2.py +172 -0
  66. passlib-1.9.5.dist-info/METADATA +90 -0
  67. passlib-1.9.5.dist-info/RECORD +69 -0
  68. passlib-1.9.5.dist-info/WHEEL +4 -0
  69. passlib-1.9.5.dist-info/licenses/LICENSE +116 -0
passlib/apps.py ADDED
@@ -0,0 +1,215 @@
1
+ from itertools import chain
2
+
3
+ from passlib import hash
4
+ from passlib.context import LazyCryptContext
5
+ from passlib.utils import sys_bits
6
+
7
+ __all__ = [
8
+ "custom_app_context",
9
+ "django_context",
10
+ "ldap_context",
11
+ "ldap_nocrypt_context",
12
+ "mysql_context",
13
+ "mysql4_context",
14
+ "mysql3_context",
15
+ "phpass_context",
16
+ "phpbb3_context",
17
+ "postgres_context",
18
+ ]
19
+
20
+
21
+ def _load_master_config():
22
+ from passlib.registry import list_crypt_handlers
23
+
24
+ # get master list
25
+ schemes = list_crypt_handlers()
26
+
27
+ # exclude the ones we know have ambiguous or greedy identify() methods.
28
+ excluded = [
29
+ # frequently confused for eachother
30
+ "bigcrypt",
31
+ "crypt16",
32
+ # no good identifiers
33
+ "cisco_pix",
34
+ "cisco_type7",
35
+ "htdigest",
36
+ "mysql323",
37
+ "oracle10",
38
+ # all have same size
39
+ "lmhash",
40
+ "msdcc",
41
+ "msdcc2",
42
+ "nthash",
43
+ # plaintext handlers
44
+ "plaintext",
45
+ "ldap_plaintext",
46
+ # disabled handlers
47
+ "django_disabled",
48
+ "unix_disabled",
49
+ ]
50
+ for name in excluded:
51
+ schemes.remove(name)
52
+
53
+ # return config
54
+ return dict(schemes=schemes, default="sha256_crypt")
55
+
56
+
57
+ master_context = LazyCryptContext(onload=_load_master_config)
58
+
59
+ custom_app_context = LazyCryptContext(
60
+ # choose some reasonbly strong schemes
61
+ schemes=["sha512_crypt", "sha256_crypt"],
62
+ # set some useful global options
63
+ default="sha256_crypt" if sys_bits < 64 else "sha512_crypt",
64
+ # set a good starting point for rounds selection
65
+ sha512_crypt__min_rounds=535000,
66
+ sha256_crypt__min_rounds=535000,
67
+ # if the admin user category is selected, make a much stronger hash,
68
+ admin__sha512_crypt__min_rounds=1024000,
69
+ admin__sha256_crypt__min_rounds=1024000,
70
+ )
71
+
72
+
73
+ # Django >= 1.0
74
+ _django10_schemes = [
75
+ "django_salted_sha1",
76
+ "django_salted_md5",
77
+ "django_des_crypt",
78
+ "hex_md5",
79
+ "django_disabled",
80
+ ]
81
+
82
+ django10_context = LazyCryptContext(
83
+ schemes=_django10_schemes,
84
+ default="django_salted_sha1",
85
+ deprecated=["hex_md5"],
86
+ )
87
+
88
+ # Django >= 1.4
89
+ _django14_schemes = [
90
+ "django_pbkdf2_sha256",
91
+ "django_pbkdf2_sha1",
92
+ "django_bcrypt",
93
+ ] + _django10_schemes
94
+
95
+ django14_context = LazyCryptContext(
96
+ schemes=_django14_schemes,
97
+ deprecated=_django10_schemes,
98
+ )
99
+
100
+ # Django >= 1.6
101
+ _django16_schemes = list(_django14_schemes)
102
+ _django16_schemes.insert(1, "django_bcrypt_sha256")
103
+ django16_context = LazyCryptContext(
104
+ schemes=_django16_schemes,
105
+ deprecated=_django10_schemes,
106
+ )
107
+
108
+ # Django >=1.10
109
+ _django_110_schemes = [
110
+ "django_pbkdf2_sha256",
111
+ "django_pbkdf2_sha1",
112
+ "django_argon2",
113
+ "django_bcrypt",
114
+ "django_bcrypt_sha256",
115
+ "django_disabled",
116
+ ]
117
+ django110_context = LazyCryptContext(
118
+ schemes=_django_110_schemes,
119
+ deprecated="auto",
120
+ )
121
+
122
+ # Django >=2.1
123
+ _django21_schemes = list(_django_110_schemes)
124
+ _django21_schemes.remove("django_bcrypt")
125
+ django21_context = LazyCryptContext(
126
+ schemes=_django21_schemes,
127
+ deprecated="auto",
128
+ )
129
+
130
+ # Django >=3.1
131
+ _django31_schemes = list(_django21_schemes)
132
+ django31_context = LazyCryptContext(
133
+ schemes=_django31_schemes,
134
+ deprecated="auto",
135
+ )
136
+
137
+ # Django latest
138
+ # this will always point to latest version in passlib
139
+ django_context = django31_context
140
+
141
+
142
+ #: standard ldap schemes
143
+ std_ldap_schemes = [
144
+ "ldap_salted_sha512",
145
+ "ldap_salted_sha256",
146
+ "ldap_salted_sha1",
147
+ "ldap_salted_md5",
148
+ "ldap_sha1",
149
+ "ldap_md5",
150
+ "ldap_plaintext",
151
+ ]
152
+
153
+ # create context with all std ldap schemes EXCEPT crypt
154
+ ldap_nocrypt_context = LazyCryptContext(std_ldap_schemes)
155
+
156
+
157
+ # create context with all possible std ldap + ldap crypt schemes
158
+ def _iter_ldap_crypt_schemes():
159
+ from passlib.utils import unix_crypt_schemes
160
+
161
+ return ("ldap_" + name for name in unix_crypt_schemes)
162
+
163
+
164
+ def _iter_ldap_schemes():
165
+ """helper which iterates over supported std ldap schemes"""
166
+ return chain(std_ldap_schemes, _iter_ldap_crypt_schemes())
167
+
168
+
169
+ ldap_context = LazyCryptContext(_iter_ldap_schemes())
170
+
171
+ ### create context with all std ldap schemes + crypt schemes for localhost
172
+ ##def _iter_host_ldap_schemes():
173
+ ## "helper which iterates over supported std ldap schemes"
174
+ ## from passlib.handlers.ldap_digests import get_host_ldap_crypt_schemes
175
+ ## return chain(std_ldap_schemes, get_host_ldap_crypt_schemes())
176
+ ##ldap_host_context = LazyCryptContext(_iter_host_ldap_schemes())
177
+
178
+ mysql3_context = LazyCryptContext(["mysql323"])
179
+ mysql4_context = LazyCryptContext(["mysql41", "mysql323"], deprecated="mysql323")
180
+ mysql_context = mysql4_context # tracks latest mysql version supported
181
+
182
+ postgres_context = LazyCryptContext(["postgres_md5"])
183
+
184
+
185
+ def _create_phpass_policy(**kwds):
186
+ """helper to choose default alg based on bcrypt availability"""
187
+ kwds["default"] = "bcrypt" if hash.bcrypt.has_backend() else "phpass"
188
+ return kwds
189
+
190
+
191
+ phpass_context = LazyCryptContext(
192
+ schemes=["bcrypt", "phpass", "bsdi_crypt"],
193
+ onload=_create_phpass_policy,
194
+ )
195
+
196
+ phpbb3_context = LazyCryptContext(["phpass"], phpass__ident="H")
197
+
198
+ # TODO: support the drupal phpass variants (see phpass homepage)
199
+
200
+
201
+ _std_roundup_schemes = [
202
+ "ldap_hex_sha1",
203
+ "ldap_hex_md5",
204
+ "ldap_des_crypt",
205
+ "roundup_plaintext",
206
+ ]
207
+ roundup10_context = LazyCryptContext(_std_roundup_schemes)
208
+
209
+ # NOTE: 'roundup15' really applies to roundup 1.4.17+
210
+ roundup_context = roundup15_context = LazyCryptContext(
211
+ schemes=_std_roundup_schemes + ["ldap_pbkdf2_sha1"],
212
+ deprecated=_std_roundup_schemes,
213
+ default="ldap_pbkdf2_sha1",
214
+ ldap_pbkdf2_sha1__default_rounds=10000,
215
+ )