Skip to content

Integrate auth adapter for Facebook accountkit login #4434

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

Merged
merged 10 commits into from
Feb 23, 2018

Conversation

6thfdwp
Copy link
Contributor

@6thfdwp 6thfdwp commented Dec 19, 2017

First time PR to parse-server, try to learn and contribute back as our app also migrated to open source parse-server since last year. Hope to be part of this community to make it robust.

@codecov
Copy link

codecov bot commented Dec 20, 2017

Codecov Report

Merging #4434 into master will decrease coverage by 0.14%.
The diff coverage is 70.58%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4434      +/-   ##
==========================================
- Coverage   92.89%   92.74%   -0.15%     
==========================================
  Files         118      119       +1     
  Lines        8445     8479      +34     
==========================================
+ Hits         7845     7864      +19     
- Misses        600      615      +15
Impacted Files Coverage Δ
src/Adapters/Auth/index.js 92.3% <100%> (+0.15%) ⬆️
src/Adapters/Auth/facebookaccountkit.js 69.69% <69.69%> (ø)
src/Adapters/Cache/InMemoryCache.js 91.66% <0%> (-8.34%) ⬇️
src/RestWrite.js 93.1% <0%> (-0.73%) ⬇️
src/Adapters/Auth/meetup.js 89.47% <0%> (+5.26%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 550b69e...154c088. Read the comment docs.

@6thfdwp
Copy link
Contributor Author

6thfdwp commented Dec 20, 2017

commit#1e8112 as required in Accountkit doc:

If you have enabled the Require App Secret setting in your app's dashboards, most calls that accept an account access token as a parameter will now require an additional appsecret_proof parameter to verify that these calls are coming from your own servers.
The app secret proof is a sha256 hash of your access token.

@montymxb
Copy link
Contributor

@6thfdwp thanks for the contribution! We're always glad to have new contributors in the community 👍 . I'm rerunning CI now as it looks like your tests are good. I'll follow up when that's done.

Copy link
Contributor

@montymxb montymxb left a comment

Choose a reason for hiding this comment

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

Looking good for an initial PR 👍 !

Couple of things that we'll need changed.

  • The error messages should be unique to this auth adapter, wouldn't want to mistake them for the other facebook one.
  • Code coverage diff should be as close to 100% as possible. In this case you can probably make a test which runs a faulty request through or the like.

Other than that this is looking good. Also it's getting a big close to the holidays so we might be a bit absent here and there 😄 .

}
});
}).on('error', function () {
reject('Failed to validate this access token with Facebook.');
Copy link
Contributor

Choose a reason for hiding this comment

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

You'll want to customize this error message as it's identical to the one for facebook auth.

if (!appIds.length) {
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Facebook app id is not configured.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Facebook app id is the same for Account Kit login, so I'll probably go like 'Facebook app id for Account Kit'

}
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Facebook app id is invalid for this user.');
Copy link
Contributor

Choose a reason for hiding this comment

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

and here

}
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Facebook auth is invalid for this user.');
Copy link
Contributor

Choose a reason for hiding this comment

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

and also here

@6thfdwp
Copy link
Contributor Author

6thfdwp commented Dec 21, 2017

Thanks for the feedback! I'll do these tweaks.

I've also actually done some local test for full request flow, all good, but this requires real access token and secret which not suitable to put in test case. But surely I can add some faulty request case with bad token etc.

Have a nice holiday! 😀

@6thfdwp
Copy link
Contributor Author

6thfdwp commented Jan 23, 2018

Hi @montymxb @flovilmart,

just check how to make this PR pass CI and other checks, I've done changes based on @montymxb review. I'd like to find new issues/enhancement to work on, hope that I can learn to get workflow right from the first PR for future commits.

Thanks!

@montymxb
Copy link
Contributor

montymxb commented Feb 1, 2018

Hey @6thfdwp , been a bit absent 😆 , haven't been around for like 2 weeks...

I've reupped to the latest changes in master and we're pending some CI here now. Looks like the last run passed but I just want to verify that this one is good. If it succeeds I'll give this a final pre-flight inspection.

Thanks for pinging us by the way! I track things mostly asynchronously using the notifications we get for the repos. Sometimes previous work can get buried while we're attempting to address what's new for a given week or day. I generally don't touch anything until I can actually respond to it, because as soon as I view anything the notification is cleared. Really wish github would allow us to reflag things for later followup or to make notifications unread.

Copy link
Contributor

@montymxb montymxb left a comment

Choose a reason for hiding this comment

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

1 typo and something that should help account for untested functionality. We won't be able to get 100% given we would need actual live appIds and a secret, which we're definitely not doing.

If you can make those couple changes that would be super 👍 .

})
});

it('should fail to validate Facebook accountkit auth with bad taken regardless of app secret proof', (done) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

typo on taken, should be token

if (!appIds.length) {
throw new Parse.Error(
Parse.Error.OBJECT_NOT_FOUND,
'Facebook app id for Account Kit is not configured.');
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add one more test to help cover this, just omit your appIds and this should trigger.

Copy link
Contributor Author

@6thfdwp 6thfdwp Feb 7, 2018

Choose a reason for hiding this comment

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

@montymxb I looked in Adapters/Auth/index.js#L50, seems in real flow, we only do validateAppId if it's provided. So in test case I provided appIds as empty array to simulate it's not properly configured

@montymxb
Copy link
Contributor

montymxb commented Feb 1, 2018

I would like to add that other than those couple things the code in this PR looks good to me. Once those are addressed I believe we should be ok to approve & merge.

@6thfdwp
Copy link
Contributor Author

6thfdwp commented Feb 2, 2018

@montymxb no worries, totally understand when facing lots of issues and requests.

I've actually used this adapter in our code base, it's been live supporting phone number login. I thought would be good to integrate and make more improvements.

Thanks for review again, I will push once I update.

@otymartin
Copy link

@6thfdwp is this live or dead?
Im looking to integrate accountkit

@6thfdwp
Copy link
Contributor Author

6thfdwp commented Feb 20, 2018

@otymartin seems still under review, waiting to be merged

@otymartin
Copy link

@flovilmart anyway we can get this approved (assuming it's production ready ) 🙏🙏

@flovilmart
Copy link
Contributor

@6thfdwp thanks for the PR, can you please update the docs alongside the PR before we merge this?

https://github.com/parse-community/docs/blob/gh-pages/_includes/parse-server/third-party-auth.md

Thanks!

@6thfdwp
Copy link
Contributor Author

6thfdwp commented Feb 23, 2018

@flovilmart just updated docs. Please review.

Thanks!

@flovilmart
Copy link
Contributor

This is looking good! Thanks!

@flovilmart flovilmart merged commit 213801c into parse-community:master Feb 23, 2018
@otymartin
Copy link

Thanks @6thfdwp

@6thfdwp
Copy link
Contributor Author

6thfdwp commented Feb 25, 2018

Awesome, thanks @flovilmart

Hope it will work, feedback welcomed @otymartin

@montymxb
Copy link
Contributor

@6thfdwp thanks for hanging in there! Sorry I wasn't able to finish this up myself, but glad to see you got this in.

UnderratedDev pushed a commit to UnderratedDev/parse-server that referenced this pull request Mar 21, 2020
* Integrate auth adapter for Facebook accountkit login

* Also verify Facebook app id associated with account kit login

* Add appsecret_proof as extra graph request parameter

* Specific error message for Account kit and more test coverage

* One more test to cover when AppIds for Facebook account kit not configured properly
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.

6 participants