-
Notifications
You must be signed in to change notification settings - Fork 598
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
storage: add getSignedPolicy function to generate a signed policy #502
Conversation
* *[Reference](http://goo.gl/JWJEkG).* | ||
* | ||
* @throws {Error} if an expiration timestamp from the past is given or | ||
* option parameter does not respect |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
assert(signedPolicy.string.indexOf(conditionString) > -1); | ||
done(); | ||
}); | ||
}); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
@stephenplusplus Feel free to bug me:) BTW, I think it is still open for discussion whether to move this method to Bucket (allowing signed policies not associated to a specific filename) or not. Adding a regression test might be useful as well. |
var conditions = []; | ||
|
||
// Populate eq conditions | ||
if (options.equals && options.equals instanceof Array) { |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
… equality and prefix conditions as 1D array. Docs updated accordingly. Added tests.
Should be ok now, even the boring stuff :) file.getSignedPolicy({
equals: ['$Content-Type', 'image/jpeg']
// ... and file.getSignedPolicy({
equals: [['$Content-Type', 'image/jpeg']]
// ... are now supported if only one condition is specified. (also for |
conditions.push(['eq', condition[0], condition[1]]); | ||
}); | ||
} | ||
} |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Thank you very much! |
Everything ok on my side, are there any more thoughts? |
expiration: expiration, | ||
startsWith: [['$<field>', '<value>']] | ||
}, function(err, signedPolicy) { | ||
console.log(signedPolicy); |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
Just a couple |
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/7a1b0b96-8ddb-4836-a1a2-d2f73b7e6ffe/targets - [ ] To automatically regenerate this PR, check this box.
Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
This PR was generated using Autosynth. 🌈 Synth log will be available here: https://source.cloud.google.com/results/invocations/541df317-e090-4c6d-88b9-3f79f53b8d13/targets - [ ] To automatically regenerate this PR, check this box. Source-Link: googleapis/synthtool@57c23fa
🤖 I have created a release \*beep\* \*boop\* --- ### [2.1.4](https://www.github.com/googleapis/nodejs-monitoring/compare/v2.1.3...v2.1.4) (2020-11-25) ### Bug Fixes * **browser:** check for fetch on window ([#501](https://www.github.com/googleapis/nodejs-monitoring/issues/501)) ([a923606](https://www.github.com/googleapis/nodejs-monitoring/commit/a9236060fdd4516e5f3fa31a5bf76895ad8bf6c1)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please).
…e in region tag (#502) * docs(samples): add auto-generated samples for Node with api short name in region tag PiperOrigin-RevId: 399287285 Source-Link: googleapis/googleapis@1575986 Source-Link: googleapis/googleapis-gen@b27fff6 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYjI3ZmZmNjIzYTVkOGQ1ODZiNzAzYjVlNDkxOTg1NmFiZTdjMmViMyJ9 * 🦉 Updates from OwlBot See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
Co-authored-by: gcf-merge-on-green[bot] <60162190+gcf-merge-on-green[bot]@users.noreply.github.com> Source-Author: F. Hinkelmann <franziska.hinkelmann@gmail.com> Source-Date: Wed Sep 30 14:13:57 2020 -0400 Source-Repo: googleapis/synthtool Source-Sha: 079dcce498117f9570cebe6e6cff254b38ba3860 Source-Link: googleapis/synthtool@079dcce
* chore(main): release 6.3.0 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com> Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
🤖 I have created a release \*beep\* \*boop\* --- ### [2.4.2](https://www.github.com/googleapis/nodejs-automl/compare/v2.4.1...v2.4.2) (2021-05-12) ### Bug Fixes * **deps:** require google-gax v2.12.0 ([#501](https://www.github.com/googleapis/nodejs-automl/issues/501)) ([f88cc91](https://www.github.com/googleapis/nodejs-automl/commit/f88cc915df6ac67f7dc46fa345d9fc481b12d7da)) * use require() to load JSON protos ([#504](https://www.github.com/googleapis/nodejs-automl/issues/504)) ([4cd9585](https://www.github.com/googleapis/nodejs-automl/commit/4cd9585da11b3a9189ed8f3f0e5ddc76c578a462)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Added a function to generate a signed policy for POST requests.
So far it supports several conditions (according to the docs):
["eq", "$<field>", "<value>"]
["starts-with", "$<field>", "<value>"]
["content-length-range", <min_range>, <max_range>]
{"bucket": "<bucket_name>"}
{"acl": "<acl_name>"}
{"success_action_redirect": "<url>"}
{"success_action_status": "<status>"}
Documentation is provided describing function arguments.
Unit tests are added.