Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ The following fields are read-only, but will be updated automatically after ever
paperless-ngx-postprocessor can be configured using the following environment variables. The defaults should work for a typical paperless-ngx deployment done via docker-compose. If you want to change them, just add them to the same `docker-compose.env` file as you use for Paperless-ngx, and they will be passed along from Paperless-ngx to paperless-ngx-postprocessor.

* `PNGX_POSTPROCESSOR_AUTH_TOKEN=<token>`: The auth token to access the REST API of Paperless-ngx. If not specified, postprocessor will try to automagically get it from Paperless-ngx's database directly. (default: `None`)
* `PNGX_POSTPROCESSOR_AUTH_TOKEN_FILE=<token_file_path>`: The auth token from a docker secret to access the REST API of Paperless-ngx . If specified, postprocessor will read the token from the given file. Will overwrite any value in PNGX_POSTPROCESSOR_AUTH_TOKEN. (default: `None`)
* `PNGX_POSTPROCESSOR_DRY_RUN=<bool>`: If set to `True`, paperless-ngx-postprocessor will not actually push any changes to paperless-ngx. (default: `False`)
* `PNGX_POSTPROCESSOR_BACKUP=<bool or path>`: Backup file to write any changed values to. If no filename is given, one will be automatically generated based on the current date and time. If the path is a directory, the automatically generated file will be stored in that directory. (default: `False`)
* `PNGX_POSTPROCESSOR_POSTPROCESSING_TAG=<tag name>`: A tag to apply if any changes are made during postprocessing. (default: `None`)
Expand Down
12 changes: 11 additions & 1 deletion paperlessngx_postprocessor/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ def general_options():
return {"auth_token": Config.OptionSpec(None, {"metavar": "AUTH_TOKEN",
"type": str,
"help": "The auth token to access the REST API of Paperless-ngx. If not specified, postprocessor will try to automagically get it from Paperless-ngx's database directly."}),
"auth_token_file": Config.OptionSpec(None, {"metavar": "AUTH_TOKEN_FILE",
"type": str,
"help": "The auth token to access the REST API of Paperless-ngx. If not specified, postprocessor will try to automagically get it from Paperless-ngx's database directly."}),
"dry_run": Config.OptionSpec(False, {"action": "store_const",
"const": True,
"help": "Don't actually make any changes, just print what would happen. Forces the verbosity level to be at least INFO. (default: {default})"}),
Expand Down Expand Up @@ -189,7 +192,14 @@ def _fix_options(self):
self._options["added_range"] = new_dates
else:
self._options["added_range"] = None


if isinstance(self._options.get("auth_token_file"), str):
token_file = self._options.get("auth_token_file")
with open(token_file, "r") as f:
token = f.readline()
if token:
self._options["auth_token"] = token

def __getitem__(self, index):
return self._options[index]

Expand Down