mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Add the possibility to customize the remote user header name
Inspired by the discussion here https://github.com/jonaswinkler/paperless-ng/discussions/639#discussion-3242017 it is worthwhile to be able to customize the header name that is used for authentication as its name is not really standardized.
This commit is contained in:
		| @@ -192,7 +192,17 @@ PAPERLESS_ENABLE_HTTP_REMOTE_USER=<bool> | |||||||
|     applications. |     applications. | ||||||
|  |  | ||||||
|     Defaults to `false` which disables this feature. |     Defaults to `false` which disables this feature. | ||||||
|  |      | ||||||
|  | PAPERLESS_HTTP_REMOTE_USER_HEADER_NAME=<strl> | ||||||
|  |     If `PAPERLESS_ENABLE_HTTP_REMOTE_USER` is enabled, this property allows to  | ||||||
|  |     customize the name of the HTTP header from which the username is extracted. | ||||||
|  |     Values are in terms of | ||||||
|  |     [HttpRequest.META](https://docs.djangoproject.com/en/3.1/ref/request-response/#django.http.HttpRequest.META). | ||||||
|  |     Thus, the configured value must start with `HTTP_` followed by the  | ||||||
|  |     normalized actual header name. | ||||||
|  |      | ||||||
|  |     Defaults to `HTTP_REMOTE_USER`. | ||||||
|  |      | ||||||
| .. _configuration-ocr: | .. _configuration-ocr: | ||||||
|  |  | ||||||
| OCR settings | OCR settings | ||||||
|   | |||||||
| @@ -33,5 +33,4 @@ class HttpRemoteUserMiddleware(RemoteUserMiddleware): | |||||||
|     """ This class allows authentication via HTTP_REMOTE_USER which is set for |     """ This class allows authentication via HTTP_REMOTE_USER which is set for | ||||||
|         example by certain SSO applications. |         example by certain SSO applications. | ||||||
|     """ |     """ | ||||||
|  |     header = settings.HTTP_REMOTE_USER_HEADER_NAME | ||||||
|     header = 'HTTP_REMOTE_USER' |  | ||||||
|   | |||||||
| @@ -189,6 +189,7 @@ if AUTO_LOGIN_USERNAME: | |||||||
|     MIDDLEWARE.insert(_index+1, 'paperless.auth.AutoLoginMiddleware') |     MIDDLEWARE.insert(_index+1, 'paperless.auth.AutoLoginMiddleware') | ||||||
|  |  | ||||||
| ENABLE_HTTP_REMOTE_USER = __get_boolean("PAPERLESS_ENABLE_HTTP_REMOTE_USER") | ENABLE_HTTP_REMOTE_USER = __get_boolean("PAPERLESS_ENABLE_HTTP_REMOTE_USER") | ||||||
|  | HTTP_REMOTE_USER_HEADER_NAME = os.getenv("PAPERLESS_HTTP_REMOTE_USER_HEADER_NAME", "HTTP_REMOTE_USER") | ||||||
|  |  | ||||||
| if ENABLE_HTTP_REMOTE_USER: | if ENABLE_HTTP_REMOTE_USER: | ||||||
|     MIDDLEWARE.append( |     MIDDLEWARE.append( | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Simon Taddiken
					Simon Taddiken