Skip to content
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

feat: Upgrade to Parse JS SDK 5 #8816

Closed
wants to merge 9 commits into from

Conversation

mtrezza
Copy link
Member

@mtrezza mtrezza commented Nov 18, 2023

Pull Request

Issue

Upgrade parse to 5 alpha; needs to be upgrade to stable release version of parse js sdk before parse server beta release

Closes: #8818

Copy link

Thanks for opening this pull request!

Copy link

codecov bot commented Nov 18, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 87.56%. Comparing base (2760381) to head (ecabfd7).
Report is 1 commits behind head on alpha.

❗ Current head ecabfd7 differs from pull request most recent head cb33371. Consider uploading reports for the commit cb33371 to get more accurate results

Additional details and impacted files
@@            Coverage Diff             @@
##            alpha    #8816      +/-   ##
==========================================
- Coverage   94.14%   87.56%   -6.58%     
==========================================
  Files         186      186              
  Lines       14677    14677              
==========================================
- Hits        13817    12852     -965     
- Misses        860     1825     +965     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mtrezza
Copy link
Member Author

mtrezza commented Nov 18, 2023

Upgrading to Parse 4.3.1 breaks a test:

  1. Security Advisory GHSA-8w3j-g983-8jh5 should validate credentials first and check if account already linked afterwards ()
  • Expected 208 to equal 206.

The test specifically expects 206 instead of 208 (as commented in the test), so it doesn't seem to be a deliberate change but rather a bug.

@mtrezza mtrezza closed this Mar 6, 2024
@mtrezza mtrezza reopened this Mar 6, 2024
@mtrezza mtrezza changed the title feat: Upgrade parse to 4.3.1 feat: Upgrade to Parse JS SDK 5 Mar 10, 2024
@mtrezza
Copy link
Member Author

mtrezza commented Mar 11, 2024

The test fails with upgrading the Parse JS SDK because it seems that #8156 refactored the auth logic in Parse Server so that a vulnerability that was previously fixed was re-introduced.

The test fails because:

  • The new Parse JS SDK removes the anonymous part from the auth data with fix: ParseUser.linkWith doesn't remove anonymous auth data Parse-SDK-JS#2007, so that the auth payload in the request contains only 1 instead of 2 auth providers, specifically, it doesn't contain the anonymous auth provider anymore.
  • The Parse Server auth logic has been refactored with feat: Improve authentication adapter interface #8156 and the following code block doesn't get executed anymore:
    if (results.length > 1) {
    // To avoid https://github.com/parse-community/parse-server/security/advisories/GHSA-8w3j-g983-8jh5
    // Let's run some validation before throwing
    await Auth.handleAuthDataValidation(authData, this, results[0]);
    throw new Parse.Error(Parse.Error.ACCOUNT_ALREADY_LINKED, 'this auth is already used');
    }
  • The code block that gets executed instead does not call Auth.handleAuthDataValidation which throws error 206. Instead, error 208 is thrown, which is what we do not want (see failing vulnerability test in ecabfd7):
    if (results.length === 1) {
    const userId = this.getUserId();
    const userResult = results[0];
    // Prevent duplicate authData id
    if (userId && userId !== userResult.objectId) {
    throw new Parse.Error(Parse.Error.ACCOUNT_ALREADY_LINKED, 'this auth is already used');
    }

I tried to just add await Auth.handleAuthDataValidation(authData, this, results[0]); to the code block, but this additional validation makes a couple of other test fail, see 6f51080. So it would help if someone with deeper understanding of the auth adapter could take a look at this. @dblythy @Moumouls @EhsanParsania

@mtrezza
Copy link
Member Author

mtrezza commented Mar 11, 2024

Just a note that this is the only PR holding back the Parse Server 7 release, so it would be great if we could get this fixed.

@mtrezza mtrezza changed the title feat: Upgrade to Parse JS SDK 5 feat: Upgrade to Parse JS SDK 5 alpha Mar 17, 2024
@mtrezza mtrezza changed the title feat: Upgrade to Parse JS SDK 5 alpha feat: Upgrade to Parse JS SDK 5-alpha Mar 17, 2024
@mtrezza mtrezza changed the title feat: Upgrade to Parse JS SDK 5-alpha feat: Upgrade to Parse JS SDK 5 Mar 17, 2024
@mtrezza
Copy link
Member Author

mtrezza commented Mar 17, 2024

Superseded by #9022

@mtrezza mtrezza closed this Mar 17, 2024
@mtrezza mtrezza deleted the feat/upgrade-parse branch May 16, 2024 16:54
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.

Upgrade to latest Parse SDK breaks test
1 participant