You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
					37 lines
				
				1.3 KiB
			
		
		
			
		
	
	
					37 lines
				
				1.3 KiB
			| 
								 
											3 years ago
										 
									 | 
							
								"""passlib.ext.django.models -- monkeypatch django hashing framework"""
							 | 
						||
| 
								 | 
							
								#=============================================================================
							 | 
						||
| 
								 | 
							
								# imports
							 | 
						||
| 
								 | 
							
								#=============================================================================
							 | 
						||
| 
								 | 
							
								# core
							 | 
						||
| 
								 | 
							
								# site
							 | 
						||
| 
								 | 
							
								# pkg
							 | 
						||
| 
								 | 
							
								from passlib.context import CryptContext
							 | 
						||
| 
								 | 
							
								from passlib.ext.django.utils import DjangoContextAdapter
							 | 
						||
| 
								 | 
							
								# local
							 | 
						||
| 
								 | 
							
								__all__ = ["password_context"]
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#=============================================================================
							 | 
						||
| 
								 | 
							
								# global attrs
							 | 
						||
| 
								 | 
							
								#=============================================================================
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#: adapter instance used to drive most of this
							 | 
						||
| 
								 | 
							
								adapter = DjangoContextAdapter()
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# the context object which this patches contrib.auth to use for password hashing.
							 | 
						||
| 
								 | 
							
								# configuration controlled by ``settings.PASSLIB_CONFIG``.
							 | 
						||
| 
								 | 
							
								password_context = adapter.context
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#: hook callers should use if context is changed
							 | 
						||
| 
								 | 
							
								context_changed = adapter.reset_hashers
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#=============================================================================
							 | 
						||
| 
								 | 
							
								# main code
							 | 
						||
| 
								 | 
							
								#=============================================================================
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								# load config & install monkeypatch
							 | 
						||
| 
								 | 
							
								adapter.load_model()
							 | 
						||
| 
								 | 
							
								
							 | 
						||
| 
								 | 
							
								#=============================================================================
							 | 
						||
| 
								 | 
							
								# eof
							 | 
						||
| 
								 | 
							
								#=============================================================================
							 |