mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Testing auth disabling mods
This commit is contained in:
		
							
								
								
									
										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"): | if os.getenv("PAPERLESS_INSTALLED_APPS"): | ||||||
|     INSTALLED_APPS += os.getenv("PAPERLESS_INSTALLED_APPS").split(",") |     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 = [ | MIDDLEWARE_CLASSES = [ | ||||||
|     'django.middleware.security.SecurityMiddleware', |     'django.middleware.security.SecurityMiddleware', | ||||||
|     'django.contrib.sessions.middleware.SessionMiddleware', |     'django.contrib.sessions.middleware.SessionMiddleware', | ||||||
|     'django.middleware.common.CommonMiddleware', |     'django.middleware.common.CommonMiddleware', | ||||||
|     'django.middleware.csrf.CsrfViewMiddleware', |     'django.middleware.csrf.CsrfViewMiddleware']\ | ||||||
|     'django.contrib.auth.middleware.AuthenticationMiddleware', |     + AUTH_CLASSES + \ | ||||||
|     'django.contrib.auth.middleware.SessionAuthenticationMiddleware', |     ['django.contrib.messages.middleware.MessageMiddleware', | ||||||
|     'django.contrib.messages.middleware.MessageMiddleware', |  | ||||||
|     'django.middleware.clickjacking.XFrameOptionsMiddleware', |     'django.middleware.clickjacking.XFrameOptionsMiddleware', | ||||||
| ] | ] | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Matt
					Matt