Comments (4)
Sorry for the trouble, and thank you for sharing what you found. I will try to reproduce.
from nodejs-storage.
Would you mind doing a fresh deploy to GCF using @google-cloud/storage@^1.5.0
? I made a change to the way errors are reported when signing fails.
from nodejs-storage.
The issue isn't actually with the signing failing, its that from 1.4.0 to 1.5.0 the actual policy output changed. I finally buckled down and created a simple test:
var storage = require('@google-cloud/storage');
var path = require('path');
var gcs = storage({
projectId: "test",
keyFilename: path.join(__dirname, "key.json")
});
var options = {
'key': "1.key",
equals: [['$Content-Type', 'application/pdf'], ['$success_action_status','200']],
successStatus: '200',
expires: '2018-12-01T06:31:42.096Z',
contentLengthRange: {
min: 0,
max: 20000000
},
};
var file = gcs.bucket("test").file("1.key");
file.getSignedPolicy(options).then(function(val){
console.log(val);
});
If you copy this code into a directory and call it test.js, and then copy a private key JSON file (downloaded from the google cloud console) into the same directory with the filename key.json, you can do the following to see the change:
[~/projects/bug] npm install @google-cloud/[email protected]
+ @google-cloud/[email protected]
added 1 package and updated 1 package in 3.088s
[~/projects/bug] node test.js
[ { string: '{"expiration":"2018-12-01T06:31:42.096Z","conditions":[["eq","$key","1.key"],{"bucket":"test"},["eq","$Content-Type","application/pdf"],["eq","$success_action_status","200"],{"success_action_status":"200"},["content-length-range",0,20000000]]}',
base64: 'eyJleHBpcmF0aW9uIjoiMjAxOC0xMi0wMVQwNjozMTo0Mi4wOTZaIiwiY29uZGl0aW9ucyI6W1siZXEiLCIka2V5IiwiMS5rZXkiXSx7ImJ1Y2tldCI6InRlc3QifSxbImVxIiwiJENvbnRlbnQtVHlwZSIsImFwcGxpY2F0aW9uL3BkZiJdLFsiZXEiLCIkc3VjY2Vzc19hY3Rpb25fc3RhdHVzIiwiMjAwIl0seyJzdWNjZXNzX2FjdGlvbl9zdGF0dXMiOiIyMDAifSxbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwwLDIwMDAwMDAwXV19',
signature: 'fdjZmFVMjqptIC9k4RFQdsijia8agVZYELpUtr7WCxxaxXzJvSrp/w+ECU7Kke9+Y/W5TxbB/ybhjZPrmA7g0m1WVVh5z+KYixz1CPs7P1ESKVuoH86FSXntYkqIoKgH8b3WKpFGkez9nI1ZYOV7oIvHpYWtFvvkkr61Pk1P/PTD5wXIUF+edWRtYbp0oA7xkhxzldMDk2xy6EkCF8obdqL/utrBi8V9yD2M56uOAhZah/R03ybJqMFxwWlZhM/0Usiq7qbp6lH8AfHYRktYcAtvl84ssgUuEzxSL0dOWj6LNalmFjSpN6TBd8It+Ma7ohqSQZZ2C0TQ9J7Yo7fzqg==' } ]
[~/projects/bug] npm install @google-cloud/[email protected]
+ @google-cloud/[email protected]
added 5 packages and updated 1 package in 4.706s
[~/projects/bug] node test.js
[ { string: '{"expiration":"2018-12-01T06:31:42.096Z","conditions":[["eq","$key","1.key"],{"bucket":"test"},["eq","$Content-Type","application/pdf"],["eq","$success_action_status","200"],{"success_action_status":"200"},["content-length-range",0,20000000]]}',
base64: 'eyJleHBpcmF0aW9uIjoiMjAxOC0xMi0wMVQwNjozMTo0Mi4wOTZaIiwiY29uZGl0aW9ucyI6W1siZXEiLCIka2V5IiwiMS5rZXkiXSx7ImJ1Y2tldCI6InRlc3QifSxbImVxIiwiJENvbnRlbnQtVHlwZSIsImFwcGxpY2F0aW9uL3BkZiJdLFsiZXEiLCIkc3VjY2Vzc19hY3Rpb25fc3RhdHVzIiwiMjAwIl0seyJzdWNjZXNzX2FjdGlvbl9zdGF0dXMiOiIyMDAifSxbImNvbnRlbnQtbGVuZ3RoLXJhbmdlIiwwLDIwMDAwMDAwXV19',
signature: 'hz/C3zdCAQfAJYCsPJ/7mC9R3PwBIDXHv7N6+eTDPNBKrdri8d89aU/Pt6DDaMhkiXgjnGx4BNLKGj6//Zrkv1vLg0PYKIky4r9u7XS6Pg+NnY2TzShmZVzuJ4sCyzcEZeJTKKIWrn1BgQJvrzeDs0ZXghJBEpknO4dMjrzkl7Op6LS/Prl1Cmv9xZ7GDY4EHleq210UR16E1s4PWWhGwAwuJT6FTJM21zQPrgb+BhAJvq8iDOcPS0Cc4HFER7slkyCB847FyezDEEP4/x2H9XoHguFZuuUDBs3IjwAvpQbIOqU2qEUvGYB4KL8XuKk+tB78pQuulrWl3F/CySyGlw==' } ]
You'll notice that for the exact same policy document and base64 data, the signature is different going from 1.4.0 to 1.5.0: there is no error, just a different signature value that isn't accepted by the cloud storage servers.
from nodejs-storage.
Thanks for that. Indeed, we changed how we were generating the signed policy. I have sent a fix in #99.
from nodejs-storage.
Related Issues (20)
- Apparently wrong type of `CopyOptions.metadata` HOT 2
- Downloading file fails when running on Node version 20.11.0 'Iron' (LTS) HOT 9
- storage acls buckets: should make a bucket public failed HOT 3
- node_modules/@google-cloud/storage/build/cjs/src/file.d.ts:7:30 - Module '"stream"' has no exported member 'PipelineSource'. HOT 5
- file file archived generations: should copy file with old versions failed HOT 2
- How to specify proxy directly on the client? HOT 1
- How to Add custom value for the header `x-goog-api` using the module google cloud storage? HOT 2
- refactor!: Revamp `apiEndpoint` HOT 1
- Implement soft delete
- Error: Cannot find module 'node:url' HOT 2
- storage acls buckets: should make a bucket public failed HOT 3
- storage requester pays existing bucket methods that accept userProject: file#createReadStream failed HOT 2
- storage requester pays existing bucket methods that accept userProject: file#getMetadata failed HOT 2
- cloud storage is authenticated but still cannot use it HOT 3
- Add object retention samples
- storage requester pays existing bucket methods that accept userProject: file#exists failed HOT 1
- Missing / undocumented feature in File.getSignedUrl() HOT 10
- Clarify the limitation message associated with bucket signed URLs
- storage HMAC keys: should get metadata for an HMAC key failed HOT 5
- storage HMAC keys: should make the key INACTIVE failed HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nodejs-storage.