mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-31 02:27:10 -04:00 
			
		
		
		
	Testing auth disabling mods
This commit is contained in:
		
							parent
							
								
									5c59120c57
								
							
						
					
					
						commit
						7f97716ae9
					
				
							
								
								
									
										16
									
								
								src/paperless/auto_auth.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										16
									
								
								src/paperless/auto_auth.py
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,16 @@ | ||||
| from django.contrib.auth.models import User | ||||
| 
 | ||||
| class User: | ||||
|     is_superuser = True | ||||
|     is_active = True | ||||
|     is_staff = True | ||||
|     id = 1 | ||||
| 
 | ||||
| def return_true(*args, **kwargs): | ||||
|     return True | ||||
| User.has_module_perms = return_true | ||||
| User.has_perm = return_true | ||||
| 
 | ||||
| class Middleware(object): | ||||
|     def process_request(self, request): | ||||
|         request.user = User() | ||||
| @ -77,14 +77,21 @@ INSTALLED_APPS = [ | ||||
| if os.getenv("PAPERLESS_INSTALLED_APPS"): | ||||
|     INSTALLED_APPS += os.getenv("PAPERLESS_INSTALLED_APPS").split(",") | ||||
| 
 | ||||
| 
 | ||||
| AUTH_CLASSES = [\ | ||||
|     'django.contrib.auth.middleware.AuthenticationMiddleware', | ||||
|     'django.contrib.auth.middleware.SessionAuthenticationMiddleware'] | ||||
| 
 | ||||
| if bool(os.getenv("PAPERLESS_DISABLE_AUTH","true").lower() in ("yes", "y", "1", "t", "true")): | ||||
|   AUTH_CLASSES = ['auto_auth.Middleware']    | ||||
| 
 | ||||
| MIDDLEWARE_CLASSES = [ | ||||
|     'django.middleware.security.SecurityMiddleware', | ||||
|     'django.contrib.sessions.middleware.SessionMiddleware', | ||||
|     'django.middleware.common.CommonMiddleware', | ||||
|     'django.middleware.csrf.CsrfViewMiddleware', | ||||
|     'django.contrib.auth.middleware.AuthenticationMiddleware', | ||||
|     'django.contrib.auth.middleware.SessionAuthenticationMiddleware', | ||||
|     'django.contrib.messages.middleware.MessageMiddleware', | ||||
|     'django.middleware.csrf.CsrfViewMiddleware']\ | ||||
|     + AUTH_CLASSES + \ | ||||
|     ['django.contrib.messages.middleware.MessageMiddleware', | ||||
|     'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||||
| ] | ||||
| 
 | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user