libpass 1.7.5.post0__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.
- libpass-1.7.5.post0.dist-info/METADATA +81 -0
- libpass-1.7.5.post0.dist-info/RECORD +69 -0
- libpass-1.7.5.post0.dist-info/WHEEL +4 -0
- libpass-1.7.5.post0.dist-info/licenses/LICENSE +116 -0
- passlib/__init__.py +3 -0
- passlib/_data/wordsets/bip39.txt +2049 -0
- passlib/_data/wordsets/eff_long.txt +7776 -0
- passlib/_data/wordsets/eff_prefixed.txt +1296 -0
- passlib/_data/wordsets/eff_short.txt +1296 -0
- passlib/_setup/__init__.py +1 -0
- passlib/_setup/stamp.py +159 -0
- passlib/apache.py +1185 -0
- passlib/apps.py +260 -0
- passlib/context.py +2066 -0
- passlib/crypto/__init__.py +1 -0
- passlib/crypto/_blowfish/__init__.py +171 -0
- passlib/crypto/_blowfish/_gen_files.py +256 -0
- passlib/crypto/_blowfish/base.py +1239 -0
- passlib/crypto/_blowfish/unrolled.py +1691 -0
- passlib/crypto/_md4.py +249 -0
- passlib/crypto/des.py +2283 -0
- passlib/crypto/digest.py +1111 -0
- passlib/crypto/scrypt/__init__.py +299 -0
- passlib/crypto/scrypt/_builtin.py +254 -0
- passlib/crypto/scrypt/_gen_files.py +161 -0
- passlib/crypto/scrypt/_salsa.py +188 -0
- passlib/exc.py +432 -0
- passlib/ext/__init__.py +1 -0
- passlib/ext/django/__init__.py +6 -0
- passlib/ext/django/models.py +38 -0
- passlib/ext/django/utils.py +1326 -0
- passlib/handlers/__init__.py +1 -0
- passlib/handlers/argon2.py +1119 -0
- passlib/handlers/bcrypt.py +1217 -0
- passlib/handlers/cisco.py +450 -0
- passlib/handlers/des_crypt.py +642 -0
- passlib/handlers/digests.py +184 -0
- passlib/handlers/django.py +545 -0
- passlib/handlers/fshp.py +223 -0
- passlib/handlers/ldap_digests.py +379 -0
- passlib/handlers/md5_crypt.py +375 -0
- passlib/handlers/misc.py +224 -0
- passlib/handlers/mssql.py +258 -0
- passlib/handlers/mysql.py +136 -0
- passlib/handlers/oracle.py +177 -0
- passlib/handlers/pbkdf2.py +521 -0
- passlib/handlers/phpass.py +142 -0
- passlib/handlers/postgres.py +61 -0
- passlib/handlers/roundup.py +33 -0
- passlib/handlers/scram.py +589 -0
- passlib/handlers/scrypt.py +413 -0
- passlib/handlers/sha1_crypt.py +173 -0
- passlib/handlers/sha2_crypt.py +657 -0
- passlib/handlers/sun_md5_crypt.py +387 -0
- passlib/handlers/windows.py +349 -0
- passlib/hash.py +111 -0
- passlib/hosts.py +112 -0
- passlib/ifc.py +354 -0
- passlib/pwd.py +813 -0
- passlib/registry.py +583 -0
- passlib/totp.py +1968 -0
- passlib/utils/__init__.py +1221 -0
- passlib/utils/binary.py +897 -0
- passlib/utils/compat/__init__.py +200 -0
- passlib/utils/decor.py +234 -0
- passlib/utils/des.py +35 -0
- passlib/utils/handlers.py +2857 -0
- passlib/utils/md4.py +34 -0
- passlib/utils/pbkdf2.py +188 -0
passlib/apps.py
ADDED
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"""passlib.apps"""
|
|
2
|
+
|
|
3
|
+
# =============================================================================
|
|
4
|
+
# imports
|
|
5
|
+
# =============================================================================
|
|
6
|
+
# core
|
|
7
|
+
import logging
|
|
8
|
+
|
|
9
|
+
log = logging.getLogger(__name__)
|
|
10
|
+
from itertools import chain
|
|
11
|
+
|
|
12
|
+
# site
|
|
13
|
+
# pkg
|
|
14
|
+
from passlib import hash
|
|
15
|
+
from passlib.context import LazyCryptContext
|
|
16
|
+
from passlib.utils import sys_bits
|
|
17
|
+
|
|
18
|
+
# local
|
|
19
|
+
__all__ = [
|
|
20
|
+
"custom_app_context",
|
|
21
|
+
"django_context",
|
|
22
|
+
"ldap_context",
|
|
23
|
+
"ldap_nocrypt_context",
|
|
24
|
+
"mysql_context",
|
|
25
|
+
"mysql4_context",
|
|
26
|
+
"mysql3_context",
|
|
27
|
+
"phpass_context",
|
|
28
|
+
"phpbb3_context",
|
|
29
|
+
"postgres_context",
|
|
30
|
+
]
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# =============================================================================
|
|
34
|
+
# master containing all identifiable hashes
|
|
35
|
+
# =============================================================================
|
|
36
|
+
def _load_master_config():
|
|
37
|
+
from passlib.registry import list_crypt_handlers
|
|
38
|
+
|
|
39
|
+
# get master list
|
|
40
|
+
schemes = list_crypt_handlers()
|
|
41
|
+
|
|
42
|
+
# exclude the ones we know have ambiguous or greedy identify() methods.
|
|
43
|
+
excluded = [
|
|
44
|
+
# frequently confused for eachother
|
|
45
|
+
"bigcrypt",
|
|
46
|
+
"crypt16",
|
|
47
|
+
# no good identifiers
|
|
48
|
+
"cisco_pix",
|
|
49
|
+
"cisco_type7",
|
|
50
|
+
"htdigest",
|
|
51
|
+
"mysql323",
|
|
52
|
+
"oracle10",
|
|
53
|
+
# all have same size
|
|
54
|
+
"lmhash",
|
|
55
|
+
"msdcc",
|
|
56
|
+
"msdcc2",
|
|
57
|
+
"nthash",
|
|
58
|
+
# plaintext handlers
|
|
59
|
+
"plaintext",
|
|
60
|
+
"ldap_plaintext",
|
|
61
|
+
# disabled handlers
|
|
62
|
+
"django_disabled",
|
|
63
|
+
"unix_disabled",
|
|
64
|
+
]
|
|
65
|
+
for name in excluded:
|
|
66
|
+
schemes.remove(name)
|
|
67
|
+
|
|
68
|
+
# return config
|
|
69
|
+
return dict(schemes=schemes, default="sha256_crypt")
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
master_context = LazyCryptContext(onload=_load_master_config)
|
|
73
|
+
|
|
74
|
+
# =============================================================================
|
|
75
|
+
# for quickly bootstrapping new custom applications
|
|
76
|
+
# =============================================================================
|
|
77
|
+
custom_app_context = LazyCryptContext(
|
|
78
|
+
# choose some reasonbly strong schemes
|
|
79
|
+
schemes=["sha512_crypt", "sha256_crypt"],
|
|
80
|
+
# set some useful global options
|
|
81
|
+
default="sha256_crypt" if sys_bits < 64 else "sha512_crypt",
|
|
82
|
+
# set a good starting point for rounds selection
|
|
83
|
+
sha512_crypt__min_rounds=535000,
|
|
84
|
+
sha256_crypt__min_rounds=535000,
|
|
85
|
+
# if the admin user category is selected, make a much stronger hash,
|
|
86
|
+
admin__sha512_crypt__min_rounds=1024000,
|
|
87
|
+
admin__sha256_crypt__min_rounds=1024000,
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# =============================================================================
|
|
91
|
+
# django
|
|
92
|
+
# =============================================================================
|
|
93
|
+
|
|
94
|
+
# -----------------------------------------------------------------------
|
|
95
|
+
# 1.0
|
|
96
|
+
# -----------------------------------------------------------------------
|
|
97
|
+
|
|
98
|
+
_django10_schemes = [
|
|
99
|
+
"django_salted_sha1",
|
|
100
|
+
"django_salted_md5",
|
|
101
|
+
"django_des_crypt",
|
|
102
|
+
"hex_md5",
|
|
103
|
+
"django_disabled",
|
|
104
|
+
]
|
|
105
|
+
|
|
106
|
+
django10_context = LazyCryptContext(
|
|
107
|
+
schemes=_django10_schemes,
|
|
108
|
+
default="django_salted_sha1",
|
|
109
|
+
deprecated=["hex_md5"],
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
# -----------------------------------------------------------------------
|
|
113
|
+
# 1.4
|
|
114
|
+
# -----------------------------------------------------------------------
|
|
115
|
+
|
|
116
|
+
_django14_schemes = [
|
|
117
|
+
"django_pbkdf2_sha256",
|
|
118
|
+
"django_pbkdf2_sha1",
|
|
119
|
+
"django_bcrypt",
|
|
120
|
+
] + _django10_schemes
|
|
121
|
+
|
|
122
|
+
django14_context = LazyCryptContext(
|
|
123
|
+
schemes=_django14_schemes,
|
|
124
|
+
deprecated=_django10_schemes,
|
|
125
|
+
)
|
|
126
|
+
|
|
127
|
+
# -----------------------------------------------------------------------
|
|
128
|
+
# 1.6
|
|
129
|
+
# -----------------------------------------------------------------------
|
|
130
|
+
|
|
131
|
+
_django16_schemes = list(_django14_schemes)
|
|
132
|
+
_django16_schemes.insert(1, "django_bcrypt_sha256")
|
|
133
|
+
django16_context = LazyCryptContext(
|
|
134
|
+
schemes=_django16_schemes,
|
|
135
|
+
deprecated=_django10_schemes,
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
# -----------------------------------------------------------------------
|
|
139
|
+
# 1.10
|
|
140
|
+
# -----------------------------------------------------------------------
|
|
141
|
+
|
|
142
|
+
_django_110_schemes = [
|
|
143
|
+
"django_pbkdf2_sha256",
|
|
144
|
+
"django_pbkdf2_sha1",
|
|
145
|
+
"django_argon2",
|
|
146
|
+
"django_bcrypt",
|
|
147
|
+
"django_bcrypt_sha256",
|
|
148
|
+
"django_disabled",
|
|
149
|
+
]
|
|
150
|
+
django110_context = LazyCryptContext(schemes=_django_110_schemes)
|
|
151
|
+
|
|
152
|
+
# -----------------------------------------------------------------------
|
|
153
|
+
# 2.1
|
|
154
|
+
# -----------------------------------------------------------------------
|
|
155
|
+
|
|
156
|
+
_django21_schemes = list(_django_110_schemes)
|
|
157
|
+
_django21_schemes.remove("django_bcrypt")
|
|
158
|
+
django21_context = LazyCryptContext(schemes=_django21_schemes)
|
|
159
|
+
|
|
160
|
+
# -----------------------------------------------------------------------
|
|
161
|
+
# latest
|
|
162
|
+
# -----------------------------------------------------------------------
|
|
163
|
+
|
|
164
|
+
# this will always point to latest version in passlib
|
|
165
|
+
django_context = django21_context
|
|
166
|
+
|
|
167
|
+
# =============================================================================
|
|
168
|
+
# ldap
|
|
169
|
+
# =============================================================================
|
|
170
|
+
|
|
171
|
+
#: standard ldap schemes
|
|
172
|
+
std_ldap_schemes = [
|
|
173
|
+
"ldap_salted_sha512",
|
|
174
|
+
"ldap_salted_sha256",
|
|
175
|
+
"ldap_salted_sha1",
|
|
176
|
+
"ldap_salted_md5",
|
|
177
|
+
"ldap_sha1",
|
|
178
|
+
"ldap_md5",
|
|
179
|
+
"ldap_plaintext",
|
|
180
|
+
]
|
|
181
|
+
|
|
182
|
+
# create context with all std ldap schemes EXCEPT crypt
|
|
183
|
+
ldap_nocrypt_context = LazyCryptContext(std_ldap_schemes)
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
# create context with all possible std ldap + ldap crypt schemes
|
|
187
|
+
def _iter_ldap_crypt_schemes():
|
|
188
|
+
from passlib.utils import unix_crypt_schemes
|
|
189
|
+
|
|
190
|
+
return ("ldap_" + name for name in unix_crypt_schemes)
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
def _iter_ldap_schemes():
|
|
194
|
+
"""helper which iterates over supported std ldap schemes"""
|
|
195
|
+
return chain(std_ldap_schemes, _iter_ldap_crypt_schemes())
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
ldap_context = LazyCryptContext(_iter_ldap_schemes())
|
|
199
|
+
|
|
200
|
+
### create context with all std ldap schemes + crypt schemes for localhost
|
|
201
|
+
##def _iter_host_ldap_schemes():
|
|
202
|
+
## "helper which iterates over supported std ldap schemes"
|
|
203
|
+
## from passlib.handlers.ldap_digests import get_host_ldap_crypt_schemes
|
|
204
|
+
## return chain(std_ldap_schemes, get_host_ldap_crypt_schemes())
|
|
205
|
+
##ldap_host_context = LazyCryptContext(_iter_host_ldap_schemes())
|
|
206
|
+
|
|
207
|
+
# =============================================================================
|
|
208
|
+
# mysql
|
|
209
|
+
# =============================================================================
|
|
210
|
+
mysql3_context = LazyCryptContext(["mysql323"])
|
|
211
|
+
mysql4_context = LazyCryptContext(["mysql41", "mysql323"], deprecated="mysql323")
|
|
212
|
+
mysql_context = mysql4_context # tracks latest mysql version supported
|
|
213
|
+
|
|
214
|
+
# =============================================================================
|
|
215
|
+
# postgres
|
|
216
|
+
# =============================================================================
|
|
217
|
+
postgres_context = LazyCryptContext(["postgres_md5"])
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
# =============================================================================
|
|
221
|
+
# phpass & variants
|
|
222
|
+
# =============================================================================
|
|
223
|
+
def _create_phpass_policy(**kwds):
|
|
224
|
+
"""helper to choose default alg based on bcrypt availability"""
|
|
225
|
+
kwds["default"] = "bcrypt" if hash.bcrypt.has_backend() else "phpass"
|
|
226
|
+
return kwds
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
phpass_context = LazyCryptContext(
|
|
230
|
+
schemes=["bcrypt", "phpass", "bsdi_crypt"],
|
|
231
|
+
onload=_create_phpass_policy,
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
phpbb3_context = LazyCryptContext(["phpass"], phpass__ident="H")
|
|
235
|
+
|
|
236
|
+
# TODO: support the drupal phpass variants (see phpass homepage)
|
|
237
|
+
|
|
238
|
+
# =============================================================================
|
|
239
|
+
# roundup
|
|
240
|
+
# =============================================================================
|
|
241
|
+
|
|
242
|
+
_std_roundup_schemes = [
|
|
243
|
+
"ldap_hex_sha1",
|
|
244
|
+
"ldap_hex_md5",
|
|
245
|
+
"ldap_des_crypt",
|
|
246
|
+
"roundup_plaintext",
|
|
247
|
+
]
|
|
248
|
+
roundup10_context = LazyCryptContext(_std_roundup_schemes)
|
|
249
|
+
|
|
250
|
+
# NOTE: 'roundup15' really applies to roundup 1.4.17+
|
|
251
|
+
roundup_context = roundup15_context = LazyCryptContext(
|
|
252
|
+
schemes=_std_roundup_schemes + ["ldap_pbkdf2_sha1"],
|
|
253
|
+
deprecated=_std_roundup_schemes,
|
|
254
|
+
default="ldap_pbkdf2_sha1",
|
|
255
|
+
ldap_pbkdf2_sha1__default_rounds=10000,
|
|
256
|
+
)
|
|
257
|
+
|
|
258
|
+
# =============================================================================
|
|
259
|
+
# eof
|
|
260
|
+
# =============================================================================
|