-
Notifications
You must be signed in to change notification settings - Fork 3
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
Add option to authenticate to secure assets #101
base: main
Are you sure you want to change the base?
Conversation
This commit adds warnings, if the exported asset's size does not match the expected size. The result made me curious, as one of the assets from the `backup.zip` test reports a warning when testing with `backupEnvironment` (the size of the `.jpg`: expected 27_093 bytes, got 27_002 bytes). Even though, this commit adds a warning for individual assets, and reports a warning count as the result of the operatoin ("Entities from environment <ENV_ID> were backd up with X warning(s) into ...). This commit takes the liberty to rephrase "backuped" -> "backed up". ``` Exporting entities from environment id <ENVIRONMENT_ID> Exporting: collections [...] Exporting: assetFolders Exporting: assets Exporting: file kontent-app.webp. Exporting: file kontent-calendar.png. Exporting: file kontent-logo-2.avif. Exporting: file kontent-ai.png. Exporting: file kai-hp-highlight-3.jpg. Size mismatch: expected 27093 bytes, got 27002 bytes. Exporting: file kai-logo-ver-black-rgb.svg. Exporting: file kai-logo-ver-neg-rgb.svg. Exporting: webhooks Exporting: webSpotlight Entities from environment <ENVIRONMENT_ID> were backd up with 1 warning(s) into 2024-11-24-10-55-backup-<ENVIRONMENT_ID>.zip. ``` Partially fixes kontent-ai#100
753d141
to
2f880a6
Compare
Investigating a way to surface warnings to users lead me to the following investigation:
I uploaded some random Because of those results, I have to question my approach in comparing the file size. However, my expectation would still be that I am hesitant to invest in changing the unit tests without a strategy regarding error handling/warnings or suitable assertions. Footnotes |
Well, it seems that there is indeed a compression step. I investigated URLs, and they differ for downloading the asset and the public URL for the asset in the UI. Unfortunately, it seems that this is how a product works, and right now, backing up an asset using this tool would mean that it is being compromised (probably some metadata is missing:/). The best we can do is submit feedback on the product if you are interested. About secure assets - the use case is not utilized by that many people as far as I know, however, we might merge your solution with slight changes if you would like to. It would mean reverting the last commit and probably in the documentation add some information about the newly added parameter, and probably a link to the Kontent. ai learn (https://kontent.ai/learn/docs/security/secure-access/javascript#a-retrieve-assets-securely). What do you think? |
This reverts commit 2f880a6.
…cureAssetDeliveryKey` Fixes kontent-ai#100
Hi @IvanKiral, I did not add the result of your investigation regarding a potential compression/metadata modification to the readme. For enterprise customers I feel the situation regarding the compression should be investigated, at least this needs clarification from my point of view. So, I can contact the support, and mention you as well, if you don't intervene. I would be also happy if you were in the position to keep track of this. |
Motivation
Currently, for environments with secure assets delivery enabled, the resulting backup contains assets with a file size of 0 kB in the assets/ folder.
This is critical as for certain users, the backup is incomplete, and no error/warning is provided.
Preposition
Support could be added by providing the bearer token to the fetching of assets.
In addition, this PR adds warnings, if the exported asset's size does not match the expected size.
The result made me curious, as one of the assets from the
backup.zip
test reports a warning when testing withbackupEnvironment
(the size of the.jpg
: expected 27_093 bytes, got 27_002 bytes).Even though, this commit adds a warning for individual assets and reports a warning count as the result of the operation ("Entities from environment <ENV_ID> were backed up with X warning(s) into ...).
This commit takes the liberty to rephrase "backuped" -> "backed up".
Only ran unit tests.
Checklist
How to test
Set up a new environment and contact Kontent.ai support to enable secure asset delivery for at least the
delivery API
.Partially resolves #100