-
Notifications
You must be signed in to change notification settings - Fork 23
feat: add Encrypt Route and Encrypt Options for existing routes #208
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
f63ce4c
Add Encrypt Route and password use to existing routes
VincentGossey ca47b67
Add docs
VincentGossey 2db86f7
fix tests after rebase changes
VincentGossey 4964152
Update readme and fix reviews
VincentGossey ab035a8
Update docs
VincentGossey e93f423
rebase and update encrypt trait
VincentGossey 370a527
fix unset in encrypt trait
VincentGossey 88b93bf
fix review
VincentGossey 1a441d8
fix Gotenberg version restriction
VincentGossey 359c543
fix doc sorting
VincentGossey b0b75cb
fix cs
VincentGossey 3e3160a
improve tests
VincentGossey ce4a64b
rebase and fix cs
VincentGossey File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,175 @@ | ||
| ## EncryptPdfBuilder | ||
| > [!TIP] | ||
| > See: [https://gotenberg.dev/docs/routes#encrypt-route](https://gotenberg.dev/docs/routes#encrypt-route) | ||
|
|
||
| ## Basic usage | ||
|
|
||
| > [!WARNING] | ||
| > As assets files, by default the PDF files are fetch in the assets folder of | ||
| > your application. | ||
| > For more information about path resolution go to [assets documentation](../assets.md). | ||
| > [!WARNING] | ||
| > You must provide at least the User Password | ||
| ```php | ||
| namespace App\Controller; | ||
|
|
||
| use Sensiolabs\GotenbergBundle\GotenbergPdfInterface; | ||
|
|
||
| class YourController | ||
| { | ||
| public function yourControllerMethod(GotenbergPdfInterface $gotenberg): Response | ||
| { | ||
| return $gotenberg->encrypt() | ||
| ->files('document_1.pdf') | ||
| ->userPassword('MyUserPassword') | ||
| ->ownerPassword('MyOwnerPassword') | ||
| ->generate() | ||
| ; | ||
| } | ||
| } | ||
| ``` | ||
| <!-- AUTO generated doc from generate.php --> | ||
| <!-- AUTO-GENERATED:START --> | ||
| ## Customization | ||
|
|
||
| ### Available methods | ||
|
|
||
| - [downloadFrom](#downloadfromarray-downloadfrom) | ||
| - [files](#filesstringablestring-paths) | ||
| - [webhook](#webhookarray-webhook) | ||
| - [webhookConfiguration](#webhookconfigurationstring-name) | ||
| - [webhookErrorRoute](#webhookerrorroutestring-route-array-parameters-string-method) | ||
| - [webhookErrorUrl](#webhookerrorurlstring-url-string-method) | ||
| - [webhookExtraHeaders](#webhookextraheadersarray-extrahttpheaders) | ||
| - [webhookRoute](#webhookroutestring-route-array-parameters-string-method) | ||
| - [webhookUrl](#webhookurlstring-url-string-method) | ||
| - [ownerPassword](#ownerpasswordstring-ownerpassword) | ||
| - [userPassword](#userpasswordstring-userpassword) | ||
|
|
||
| ### downloadFrom(array \$downloadFrom) | ||
| Sets download from to download each entry (file) in parallel (URLs MUST return a Content-Disposition header with a filename parameter.).<br /> | ||
|
|
||
| > [!TIP] | ||
| > See: [https://gotenberg.dev/docs/routes#download-from](https://gotenberg.dev/docs/routes#download-from) | ||
|
|
||
| ```php | ||
| return $gotenberg | ||
| // Your builder call as ->html() and the rest of your configuration code | ||
| ->downloadFrom([['url' => 'http://example.com/url/to/file', 'extraHttpHeaders' => ['MyHeader' => 'MyValue']], ['url' => 'http://example.com/url/to/file', 'extraHttpHeaders' => ['MyHeaderOne' => 'MyValue', 'MyHeaderTwo' => 'MyValue']]]) | ||
| ->generate() | ||
| ->stream() | ||
| ; | ||
| ``` | ||
|
|
||
| ### files(Stringable|string ...\$paths) | ||
|
|
||
| ### webhook(array \$webhook) | ||
| > [!TIP] | ||
| > See: [https://gotenberg.dev/docs/webhook](https://gotenberg.dev/docs/webhook) | ||
|
|
||
| ```php | ||
| return $gotenberg | ||
| // Your builder call as ->html() and the rest of your configuration code | ||
| ->webhook(['config_name' => 'my_config', 'success' => ['url' => 'https://my.webhook.url/success', 'method' => 'POST'], 'error' => ['route' => 'my_route_error', 'method' => 'POST']]) | ||
| ->generate() | ||
| ->stream() | ||
| ; | ||
| ``` | ||
|
|
||
| ### webhookConfiguration(string \$name) | ||
| Providing an existing $name from the configuration file, it will correctly set both success and error webhook URLs as well as extra_http_headers if defined.<br /> | ||
|
|
||
| ```php | ||
| return $gotenberg | ||
| // Your builder call as ->html() and the rest of your configuration code | ||
| ->webhookConfiguration('my_webhook_config') | ||
| ->generate() | ||
| ->stream() | ||
| ; | ||
| ``` | ||
|
|
||
| ### webhookErrorRoute(string \$route, array \$parameters, ?string \$method) | ||
| Sets the webhook route with params and method for cases of error.<br /> | ||
|
|
||
| ```php | ||
| return $gotenberg | ||
| // Your builder call as ->html() and the rest of your configuration code | ||
| ->webhookErrorRoute('my_route_error', ['foo' => 'bar'], 'PUT') | ||
| ->generate() | ||
| ->stream() | ||
| ; | ||
| ``` | ||
|
|
||
| ### webhookErrorUrl(string \$url, ?string \$method) | ||
| Sets the webhook for cases of success.<br />Optionally sets a custom HTTP method for such endpoint among : POST, PUT or PATCH.<br /> | ||
|
|
||
| ```php | ||
| return $gotenberg | ||
| // Your builder call as ->html() and the rest of your configuration code | ||
| ->webhookErrorUrl('https://my.webhook.url', 'PUT') | ||
| ->generate() | ||
| ->stream() | ||
| ; | ||
| ``` | ||
|
|
||
| ### webhookExtraHeaders(array \$extraHttpHeaders) | ||
| Extra headers that will be provided to the webhook endpoint. May it either be Success or Error.<br /> | ||
|
|
||
| ```php | ||
| return $gotenberg | ||
| // Your builder call as ->html() and the rest of your configuration code | ||
| ->webhookExtraHeaders(['Authorization' => 'Bearer my-secret-token','X-Custom-Header' => 'CustomValue']) | ||
| ->generate() | ||
| ->stream() | ||
| ; | ||
| ``` | ||
|
|
||
| ### webhookRoute(string \$route, array \$parameters, ?string \$method) | ||
| Sets the webhook route with params and method for cases of success.<br /> | ||
|
|
||
| ```php | ||
| return $gotenberg | ||
| // Your builder call as ->html() and the rest of your configuration code | ||
| ->webhookRoute('my_route_success', ['foo' => 'bar'], 'PUT') | ||
| ->generate() | ||
| ->stream() | ||
| ; | ||
| ``` | ||
|
|
||
| ### webhookUrl(string \$url, ?string \$method) | ||
| Sets the webhook for cases of success.<br />Optionally sets a custom HTTP method for such endpoint among : POST, PUT or PATCH.<br /> | ||
|
|
||
| ```php | ||
| return $gotenberg | ||
| // Your builder call as ->html() and the rest of your configuration code | ||
| ->webhookUrl('https://my.webhook.url', 'PUT') | ||
| ->generate() | ||
| ->stream() | ||
| ; | ||
| ``` | ||
|
|
||
|
|
||
| ### ownerPassword(?string \$ownerPassword) | ||
| Set PDF owner password.<br /> | ||
|
|
||
| ```php | ||
| return $gotenberg | ||
| // Your builder call as ->html() and the rest of your configuration code | ||
| ->ownerPassword('OwnerDefinedPassword') | ||
| ->generate() | ||
| ->stream() | ||
| ; | ||
| ``` | ||
|
|
||
| ### userPassword(?string \$userPassword) | ||
| Set PDF user password.<br /> | ||
|
|
||
| ```php | ||
| return $gotenberg | ||
| // Your builder call as ->html() and the rest of your configuration code | ||
| ->userPassword('UserDefinedPassword') | ||
| ->generate() | ||
| ->stream() | ||
| ; | ||
| ``` | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.