Skip to content

Firebase authentication provider is implemented #3174

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

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"commander": "2.9.0",
"deepcopy": "0.6.3",
"express": "4.14.0",
"firebase-admin": "^4.0.3",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure we want to depend on that module for every single user.

You can probably provide that module externally.

Copy link
Author

@mockitor mockitor Dec 4, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i'll try to provide externally. thanks for your feedback.

"intersect": "1.0.1",
"lodash": "4.17.2",
"lru-cache": "4.0.2",
Expand Down
41 changes: 41 additions & 0 deletions src/authDataManager/firebase.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Helper functions for accessing the qq Graph API.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad comment.

var Parse = require('parse/node').Parse;
var admin = require("firebase-admin");


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line

var firebaseServiceAccount = process.env.FIREBASE_SERVICE_ACCOUNT;
if (firebaseServiceAccount != null) {
admin.initializeApp({
credential: admin.credential.cert(require(firebaseServiceAccount))
});
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line

// Returns a promise that fulfills iff this user id is valid.
function validateAuthData(authData) {
if (firebaseServiceAccount == null || firebaseServiceAccount == "") {
throw new Parse.Error(Parse.Error.FILE_READ_ERROR, "Firebase service account file not exists");
}

return admin.auth().verifyIdToken(authData.access_token)
.then(function (decodedToken) {
if (decodedToken == null || decodedToken.uid == null || decodedToken.uid == "") {
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, "Firebase user not found");
}
return;
}).catch(function (error) {
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, error.message);
});

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line

}

// Returns a promise that fulfills if this app id is valid.
function validateAppId() {
return Promise.resolve();
}


Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line

module.exports = {
validateAppId,
validateAuthData
};
5 changes: 4 additions & 1 deletion src/authDataManager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ let vkontakte = require("./vkontakte");
let qq = require("./qq");
let wechat = require("./wechat");
let weibo = require("./weibo");
let firebase = require("./firebase");

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line


let anonymous = {
validateAuthData: () => {
Expand All @@ -39,7 +41,8 @@ let providers = {
vkontakte,
qq,
wechat,
weibo
weibo,
firebase
}

module.exports = function(oauthOptions = {}, enableAnonymousUsers = true) {
Expand Down