mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-10-30 03:56:23 -05:00 
			
		
		
		
	Removed ability to encrypt documents.
This commit is contained in:
		| @@ -353,39 +353,23 @@ Documents can be stored in Paperless using GnuPG encryption. | ||||
|     Consider running paperless on an encrypted filesystem instead, which will then | ||||
|     at least provide security against physical hardware theft. | ||||
|  | ||||
| .. code:: | ||||
|  | ||||
|     change_storage_type [--passphrase PASSPHRASE] {gpg,unencrypted} {gpg,unencrypted} | ||||
|  | ||||
|     positional arguments: | ||||
|       {gpg,unencrypted}     The state you want to change your documents from | ||||
|       {gpg,unencrypted}     The state you want to change your documents to | ||||
|  | ||||
|     optional arguments: | ||||
|       --passphrase PASSPHRASE | ||||
|  | ||||
| Enabling encryption | ||||
| ------------------- | ||||
|  | ||||
| Basic usage to enable encryption of your document store (**USE A MORE SECURE PASSPHRASE**): | ||||
|  | ||||
| (Note: If ``PAPERLESS_PASSPHRASE`` isn't set already, you need to specify it here) | ||||
|  | ||||
| .. code:: | ||||
|  | ||||
|     change_storage_type [--passphrase SECR3TP4SSPHRA$E] unencrypted gpg | ||||
| Enabling encryption is no longer supported. | ||||
|  | ||||
|  | ||||
| Disabling encryption | ||||
| -------------------- | ||||
|  | ||||
| Basic usage to enable encryption of your document store: | ||||
| Basic usage to disable encryption of your document store: | ||||
|  | ||||
| (Note: Again, if ``PAPERLESS_PASSPHRASE`` isn't set already, you need to specify it here) | ||||
| (Note: If ``PAPERLESS_PASSPHRASE`` isn't set already, you need to specify it here) | ||||
|  | ||||
| .. code:: | ||||
|  | ||||
|     change_storage_type [--passphrase SECR3TP4SSPHRA$E] gpg unencrypted | ||||
|     decrypt_documents [--passphrase SECR3TP4SSPHRA$E] | ||||
|  | ||||
|  | ||||
| .. _Pipenv: https://pipenv.pypa.io/en/latest/ | ||||
| @@ -17,16 +17,6 @@ class Command(BaseCommand): | ||||
| 
 | ||||
|     def add_arguments(self, parser): | ||||
| 
 | ||||
|         parser.add_argument( | ||||
|             "from", | ||||
|             choices=("gpg", "unencrypted"), | ||||
|             help="The state you want to change your documents from" | ||||
|         ) | ||||
|         parser.add_argument( | ||||
|             "to", | ||||
|             choices=("gpg", "unencrypted"), | ||||
|             help="The state you want to change your documents to" | ||||
|         ) | ||||
|         parser.add_argument( | ||||
|             "--passphrase", | ||||
|             help="If PAPERLESS_PASSPHRASE isn't set already, you need to " | ||||
| @@ -50,11 +40,6 @@ class Command(BaseCommand): | ||||
|         except KeyboardInterrupt: | ||||
|             return | ||||
| 
 | ||||
|         if options["from"] == options["to"]: | ||||
|             raise CommandError( | ||||
|                 'The "from" and "to" values can\'t be the same.' | ||||
|             ) | ||||
| 
 | ||||
|         passphrase = options["passphrase"] or settings.PASSPHRASE | ||||
|         if not passphrase: | ||||
|             raise CommandError( | ||||
| @@ -62,10 +47,7 @@ class Command(BaseCommand): | ||||
|                 "by declaring it in your environment or your config." | ||||
|             ) | ||||
| 
 | ||||
|         if options["from"] == "gpg" and options["to"] == "unencrypted": | ||||
|         self.__gpg_to_unencrypted(passphrase) | ||||
|         elif options["from"] == "unencrypted" and options["to"] == "gpg": | ||||
|             self.__unencrypted_to_gpg(passphrase) | ||||
| 
 | ||||
|     @staticmethod | ||||
|     def __gpg_to_unencrypted(passphrase): | ||||
| @@ -94,27 +76,3 @@ class Command(BaseCommand): | ||||
| 
 | ||||
|             for path in old_paths: | ||||
|                 os.unlink(path) | ||||
| 
 | ||||
|     @staticmethod | ||||
|     def __unencrypted_to_gpg(passphrase): | ||||
| 
 | ||||
|         unencrypted_files = Document.objects.filter( | ||||
|             storage_type=Document.STORAGE_TYPE_UNENCRYPTED) | ||||
| 
 | ||||
|         for document in unencrypted_files: | ||||
| 
 | ||||
|             print(coloured("Encrypting {}".format(document), "green")) | ||||
| 
 | ||||
|             old_paths = [document.source_path, document.thumbnail_path] | ||||
|             with open(document.source_path, "rb") as raw_document: | ||||
|                 with open(document.thumbnail_path, "rb") as raw_thumb: | ||||
|                     document.storage_type = Document.STORAGE_TYPE_GPG | ||||
|                     with open(document.source_path, "wb") as f: | ||||
|                         f.write(GnuPG.encrypted(raw_document, passphrase)) | ||||
|                     with open(document.thumbnail_path, "wb") as f: | ||||
|                         f.write(GnuPG.encrypted(raw_thumb, passphrase)) | ||||
| 
 | ||||
|             document.save(update_fields=("storage_type",)) | ||||
| 
 | ||||
|             for path in old_paths: | ||||
|                 os.unlink(path) | ||||
		Reference in New Issue
	
	Block a user
	 Jonas Winkler
					Jonas Winkler