Skip to content

Conversation

jwngr
Copy link

@jwngr jwngr commented Apr 13, 2017

Description

Still very much a WIP, but this is a prototype which adds GCS support via admin.storage(). admin.storage().bucket exports the standard GCS Bucket API.

Initialization of the underlying google-cloud SDK is probably going to be a bit tricky since they don't provide a standard credential interface like our SDK does which allows you to provide your own Google OAuth2 access tokens. But we can make it work without too much effort via the certificate credential (which this PR does) and via the Application Default Credential (which this PR does not do). I'm still not sure how we will make it work using a refresh token credential since we don't have the right fields that the google-cloud SDK provides as initialization options (see the table in "Advanced Usage" here).

I didn't do anything for multi-bucket support although it shouldn't be too bad to support.

cc/ @mcdonamp, @sphippen, @hiranya911, @depoll

Code sample

var admin = require('firebase-admin');

var serviceAccount = require('./path/to/key.json');

admin.initializeApp({
  credential: admin.credential.cert(serviceAccount),
  storageBucket: 'admin-sdks-test.appspot.com',
});

admin.storage().bucket.file('firebase.png').download({
  destination: './firebase.png'
}, function(error) {
  if (error) {
    console.log('Error downloading file:', error);
  } else {
    console.log('File successfully downloaded!');
  }
});

Jacob Wenger and others added 30 commits July 7, 2016 14:20
Change-Id: I5fa942e199b040743b3fc6b15c91f31a2b057418
Change-Id: I330e41d75bd3a1489242067e4bc5c79b1c9211ea
Change-Id: Icb631e1e67401d53d729632763d50819a41ea420
Change-Id: I709985ad3deabb56c92aa3744ad7e9d5eaa4a016
Change-Id: Ie6242994c7bfaa9a3c945250d7c95330bd8af09b
Change-Id: I6e2cf9eb7835d03764405693e3ad40658f946bb6
Change-Id: I48a6079a5b15bd814318f93b2656582ebf11b285
Change-Id: I2d135f556e1611ca05f17f7bc88784b3c6958105
Change-Id: I6c7b9524590e0a3ab95a1e27db52ae4d886cd28a
Change-Id: I49f701b3614a7c357c8499558bb177a7bc9fa580
Change-Id: Id807e9f5b71d330087b51e28f38fec9e324d3f4e
Change-Id: Iec2e8511431c9ed97d5165a76717f2669778c4ab
…ackend.

Change-Id: I3f7ff0b5e3b08d5616509ec8266e28f0724f9074
…esponsible for deleting users. Implements the bulk of firebase.auth.Auth.prototype.getUser(), firebase.auth.Auth.prototype.getUserByEmail(), firebase.auth.Auth.prototype.deleteUser() as defined in the user management auth node.js API proposal: https://docs.google.com/document/d/1XY8O37rP9ySrZ5G3V4y3GELqKu1ZO9MtJga6135rcY0/

Change-Id: I14aa39e90416512eaf53e01318f21be817c79b41
…ndler responsible for deleting users. Implements the bulk of firebase.auth.Auth.prototype.getUser(), firebase.auth.Auth.prototype.getUserByEmail(), firebase.auth.Auth.prototype.deleteUser() as defined in the user management auth node.js API proposal: https://docs.google.com/document/d/1XY8O37rP9ySrZ5G3V4y3GELqKu1ZO9MtJga6135rcY0/"
Change-Id: I06cb29d5d3554e985ed3274bbdfa50d506bfb44f
…e user requests.

Currently for update operations, setAccountInfo endpoint is to be used.
For create operations, signupNewUser is used when no uid is provided whereas uploadAccount
endpoint is used when a uid is provided. allowOverwrite: false is passed in request to throw
an error when the user exists.

A temporary validator utility file has been created as a placeholder for now to validate
the properties in the request.
It is recommended that we replace that with some other npm module like validator.

Implementation is based on the specs defines in the API proposal:
https://docs.google.com/document/d/1XY8O37rP9ySrZ5G3V4y3GELqKu1ZO9MtJga6135rcY0/

Change-Id: Ia7b1371135b8e814102740ace4b2bf2fb9564e8a
…d create user requests. Currently for update operations, setAccountInfo endpoint is to be used. For create operations, signupNewUser is used when no uid is provided whereas uploadAccount endpoint is used when a uid is provided. allowOverwrite: false is passed in request to throw an error when the user exists."
Change-Id: I256e732df81ef1004c435bd374dbd58874380414
…updateUser which

call underlying auth request handler updateExistingAccount and createNewAccount.
A user record is then populated from the user lookup of the uid returned and returned
to the developer.

In addition, adds the validators for Firebase auth uid and password.

Finally, adds spy checks on isUid, isPassword, isURL, isEmail during request validation
tests.

Implementation is based on the specs defines in the API proposal:
https://docs.google.com/document/d/1XY8O37rP9ySrZ5G3V4y3GELqKu1ZO9MtJga6135rcY0/

Change-Id: I128406922e6b69aa16bd0d50101f11ec294e13df
…er and updateUser which call underlying auth request handler updateExistingAccount and createNewAccount. A user record is then populated from the user lookup of the uid returned and returned to the developer."
Change-Id: Ia1d0f26b03d025bfd6d565bac849b05cdd4a9601
jwngr and others added 20 commits March 7, 2017 11:26
Change-Id: Ieaa772a1521c3b888e15de0fa7e74f9a34ee6391
It’s possible a user could provide a string type error (instead of an
actual Error object) when defining a custom Credential.getAccessToken()
method, and we should be able handle that case.

Change-Id: Ib1d800584466a1b44093131d36a250ce2bc9a701
Change-Id: I4425cb87ebf903bbcc4c4194174f6be439602301
Change-Id: I75727865174d9c0c6523be932bffe678c216ba20
Testing Jenkins job
Change-Id: I1f6d47234ea2650409239d2fae07157da249a3dc
@jwngr jwngr self-assigned this Apr 13, 2017
Change-Id: I0164e99969bc072512b568ddb9dfe425d83c184d
@jwngr jwngr assigned hiranya911 and unassigned jwngr Apr 14, 2017
@hiranya911 hiranya911 closed this May 4, 2017
@hiranya911 hiranya911 deleted the jw-gcloud branch May 4, 2017 19:19
@hiranya911 hiranya911 restored the jw-gcloud branch May 6, 2017 01:08
@hiranya911 hiranya911 deleted the jw-gcloud branch May 21, 2018 17:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants