Skip to content

Sign in with Ethereum: domain and origin should compare without port#18296

Closed
yonigoldberg wants to merge 4 commits intoMetaMask:developfrom
yonigoldberg:develop
Closed

Sign in with Ethereum: domain and origin should compare without port#18296
yonigoldberg wants to merge 4 commits intoMetaMask:developfrom
yonigoldberg:develop

Conversation

@yonigoldberg
Copy link
Copy Markdown

Explanation

The parsed SIWE domain doesn't have a port (e.g loclhost) therefore when it is compared with the origin, the host from the origin should be without a port as well. That is achieved by using hostname instead of host.

Screenshots/Screencaps

Before

image

### After

image

## Manual Testing Steps - Run any local server and try to login with SIWE

Pre-merge author checklist

  • I've clearly explained:
    • What problem this PR is solving
    • How this problem was solved
    • How reviewers can test my changes
  • Sufficient automated test coverage has been added

Pre-merge reviewer checklist

  • Manual testing (e.g. pull and build branch, run in browser, test code being changed)
  • PR is linked to the appropriate GitHub issue
  • IF this PR fixes a bug in the release milestone, add this PR to the release milestone

If further QA is required (e.g. new feature, complex testing steps, large refactor), add the Extension QA Board label.

In this case, a QA Engineer approval will be be required.

@yonigoldberg yonigoldberg requested a review from a team as a code owner March 23, 2023 02:45
@yonigoldberg yonigoldberg requested a review from Gtonizuka March 23, 2023 02:45
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 23, 2023

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@yonigoldberg
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@yonigoldberg yonigoldberg force-pushed the develop branch 2 times, most recently from d839df4 to 9b0beb7 Compare March 23, 2023 04:52
@skgbafa
Copy link
Copy Markdown
Contributor

skgbafa commented Mar 23, 2023

Amazing, came to the repo to make this exact change. The hostname will always map to the domain and drop the port, preventing the domain binding bug from happening on localhost. This change looks great to me.

@yonigoldberg yonigoldberg reopened this Mar 23, 2023
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 23, 2023
@yonigoldberg yonigoldberg force-pushed the develop branch 3 times, most recently from 2db2321 to b97c019 Compare March 23, 2023 17:37
digiwand
digiwand previously approved these changes Mar 26, 2023
Copy link
Copy Markdown
Contributor

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

Lgtm! Thanks for adding the fix and test for this @yonigoldberg!

I think it'd be a good idea to add another test to check the case where domain contains the port number as well. I don't think this is a blocker for this PR, though I think we should add it here or in a follow-up PR

The parsed SIWE domain might or might not have a port, therefore when
it is compared with the origin it should handle both cases.
Comment thread ui/components/app/signature-request-siwe/signature-request-siwe.js Outdated
Copy link
Copy Markdown
Contributor

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

re: @naugtur comment above

I think that's a good idea to limit the scope to localhost. Blocking this PR now to apply the change and continue the discussion above.

…e.js

Co-authored-by: Zbyszek Tenerowicz <naugtur@gmail.com>
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 29, 2023

Codecov Report

Merging #18296 (f88a089) into develop (4179ce6) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

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

@@             Coverage Diff             @@
##           develop   #18296      +/-   ##
===========================================
- Coverage    64.55%   64.55%   -0.00%     
===========================================
  Files          919      919              
  Lines        35445    35446       +1     
  Branches      9119     9120       +1     
===========================================
- Hits         22880    22879       -1     
- Misses       12565    12567       +2     
Impacted Files Coverage Δ
...p/signature-request-siwe/signature-request-siwe.js 68.09% <100.00%> (+0.69%) ⬆️

... and 2 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

digiwand
digiwand previously approved these changes Mar 29, 2023
@legobeat
Copy link
Copy Markdown
Contributor

legobeat commented Mar 30, 2023

Left some thoughts @ #18188. PTAL.

jpuri
jpuri previously approved these changes Mar 30, 2023
@jpuri
Copy link
Copy Markdown
Contributor

jpuri commented Mar 30, 2023

Hey @yonigoldberg : can you plz fix lint issue.

Comment thread ui/components/app/signature-request-siwe/signature-request-siwe.js Outdated
@digiwand digiwand dismissed stale reviews from jpuri and themself via 5034102 March 31, 2023 16:58
@digiwand digiwand requested review from jpuri and naugtur March 31, 2023 22:07
Copy link
Copy Markdown
Contributor

@digiwand digiwand left a comment

Choose a reason for hiding this comment

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

having an interesting conversation with @legobeat.

@yonigoldberg, we will need to hold off on merging this right now while we figure this out. Thank you for your patience with this. I am curious to know if you have found a workaround the match the port numbers in the meantime. Hoping you have


For clarification, I'm realizing the issue ticket that is currently related to this PR is only concerned with the http/https protocol rather than the port. maybe we can unrelate the tickets or combine the issues

Other related tickets:

  • Support domain mismatch on SIWE on development mode #18191
  • [Bug]: Weird behavior for SIWE requests on localhost #18188
  • addressing subdomains (e.g. www) - (#18332)

@digiwand digiwand added the DO-NOT-MERGE Pull requests that should not be merged label Apr 1, 2023
@yonigoldberg
Copy link
Copy Markdown
Author

Per the conversation in #18188 I think we can close this PR.

@github-actions github-actions Bot locked and limited conversation to collaborators Apr 6, 2023
@legobeat
Copy link
Copy Markdown
Contributor

legobeat commented Apr 6, 2023

Thank you for opening this PR, your input, and keeping the conversation moving @yonigoldberg

@digiwand
Copy link
Copy Markdown
Contributor

digiwand commented Apr 7, 2023

^ +1

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

DO-NOT-MERGE Pull requests that should not be merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: Weird behavior for SIWE requests on localhost

6 participants