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

Add hostname and extensionId to site metadata #7218

Merged
merged 1 commit into from
Oct 29, 2019

Conversation

Gudahtt
Copy link
Member

@Gudahtt Gudahtt commented Sep 25, 2019

The hostname is now used as a fallback in case the siteTitle is missing from the metadata (as it would be for connections with extensions).

The artificial hostname set for internal connections has been renamed from 'MetaMask' to 'metamask' because URL objects automatically normalize hostnames to be all lower-case, and it was more convenient to use a URL object so that the parameter would be the same type as used for an untrusted connection.

@Gudahtt
Copy link
Member Author

Gudahtt commented Sep 25, 2019

@coinsquareMike is this a suitable alternative to #7169 ? Let me know if this meets your needs, or if anything is still missing.

The title is pretty ugly right now for an extension (it has the full origin, including protocol). I might switch things around to use the hostname as the title instead, and use the full origin for the light-grey text below the title.

@metamaskbot
Copy link
Collaborator

Builds ready [e63cb33]

@deluca-mike
Copy link

deluca-mike commented Oct 2, 2019

@Gudahtt This does work, however, the resulting UI for the approval is ugly less than ideal:

Screen Shot 2019-10-01 at 9 19 09 PM
Screen Shot 2019-10-01 at 9 19 21 PM

However, it is a good starting point. Additional work can be done on the UI side to show "An extension" when that extension:// prefix is detected.

For now though, this absolutely resolves the issue.

@Gudahtt
Copy link
Member Author

Gudahtt commented Oct 2, 2019

@coinsquareMike great, thanks for the feedback! I'll see if i can improve the UI before this is merged.

@Gudahtt Gudahtt force-pushed the add-hostname-and-extension-id-to-site-metadata branch 2 times, most recently from 1dea2a9 to 2e2c620 Compare October 3, 2019 12:57
@metamaskbot
Copy link
Collaborator

Builds ready [2e2c620]

@Gudahtt Gudahtt force-pushed the add-hostname-and-extension-id-to-site-metadata branch from 2e2c620 to 69a8aec Compare October 3, 2019 13:50
@Gudahtt
Copy link
Member Author

Gudahtt commented Oct 3, 2019

The UI has been updated to use the title External Extension, and the subtitle Extension ID: '[id]'

extension_connect_request

I think this is good enough for the initial implementation. It definitely could use more emphasis on the extension ID so that the user knows that's the only trustworthy piece of information, and maybe a link to a help article explaining how to verify it.

@metamaskbot
Copy link
Collaborator

Builds ready [69a8aec]

If the extension ID is set, an alternate title and subtitle are used
for the Connect Request screen. The title is always `External
Extension`, and the subtitle is `Extension ID: [id]` instead of the
origin (which would just be `[extension-scheme]://[id]` anyway).

The hostname for the site is used as a fallback in case it has no
title.

The artificial hostname set for internal connections has been renamed
from 'MetaMask' to 'metamask' because URL objects automatically
normalize hostnames to be all lower-case, and it was more convenient to
use a URL object so that the parameter would be the same type as used
for an untrusted connection.
@Gudahtt Gudahtt force-pushed the add-hostname-and-extension-id-to-site-metadata branch from 69a8aec to 4aa297d Compare October 17, 2019 01:57
@metamaskbot
Copy link
Collaborator

Builds ready [4aa297d]

@rekmarks
Copy link
Member

rekmarks commented Oct 24, 2019

These changes are mostly incompatible with the site metadata handling in #7004. There, site metadata retrieval has been moved completely to metamask-inpage-provider while the background and UI retrieve it from state as necessary. In addition, the provider approval controller has been removed.

What we do about that in relation to this PR depends on when we intend to merge #7004. I think almost all of what's done here will need to be moved/re-implemented when we do.

@Gudahtt
Copy link
Member Author

Gudahtt commented Oct 24, 2019

Generally I don't think moving the metadata retrieval to the metamask-inpage-provider is an obstacle to this change, as that collection isn't used for other extensions. We don't inject anything into extensions, so there is no opportunity for us to collect it. Instead the metadata is gathered from the connection itself, the one we're already using (onConnectExternal in background.js), as an alternative to collecting metadata from the contentscript. That aspect remains unchanged on #7004, so I'd expect this to work fine there as well.

The changes to the providerApproval controller will certainly need to be migrated, as will the addition of the hostname to the site metadata. I can take responsibility for that; I'll create a PR against the #7004 branch.

Copy link
Contributor

@whymarrh whymarrh left a comment

Choose a reason for hiding this comment

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

Seems legit

@Gudahtt Gudahtt merged commit 8dfb0e8 into develop Oct 29, 2019
@whymarrh whymarrh deleted the add-hostname-and-extension-id-to-site-metadata branch October 29, 2019 20:59
Gudahtt added a commit that referenced this pull request Nov 4, 2019
The site metadata was updated in #7218 to include the extension id of
the extension connecting to MetaMask. This was done to allow external
extensions to connect with MetaMask, so that we could show the id on
the provider approval screen.

Unbeknownst to me at the time, the extension id was being set for all
connections to MetaMask from dapps. The id was set to MetaMask's id,
because the connections are made through MetaMask's contentscript.

This has been updated to only set the id when accepting a connection
from a different extension.
Gudahtt added a commit that referenced this pull request Nov 4, 2019
In #7218 a few things were added to the site metadata, so the provider
approval controller was middleware was updated to accept the site
metadata as an object rather than accepting each property as a separate
parameter. Unfortunately we failed to notice that the site name and
icon were named differently in the site metadata than they were in the
provider approval controller, so the names of those properties were
unintentionally changed in the controller state.

The provider approval controller has been updated to restore the
original property names of `siteTitle` and `siteIcon`. An unused prop
that was added to the provider approval page in #7218 has also been
removed.
Gudahtt added a commit that referenced this pull request Nov 4, 2019
* Omit MetaMask `extensionId` from site metadata

The site metadata was updated in #7218 to include the extension id of
the extension connecting to MetaMask. This was done to allow external
extensions to connect with MetaMask, so that we could show the id on
the provider approval screen.

Unbeknownst to me at the time, the extension id was being set for all
connections to MetaMask from dapps. The id was set to MetaMask's id,
because the connections are made through MetaMask's contentscript.

This has been updated to only set the id when accepting a connection
from a different extension.

* Fix `siteMetadata` property names

In #7218 a few things were added to the site metadata, so the provider
approval controller was middleware was updated to accept the site
metadata as an object rather than accepting each property as a separate
parameter. Unfortunately we failed to notice that the site name and
icon were named differently in the site metadata than they were in the
provider approval controller, so the names of those properties were
unintentionally changed in the controller state.

The provider approval controller has been updated to restore the
original property names of `siteTitle` and `siteIcon`. An unused prop
that was added to the provider approval page in #7218 has also been
removed.
Gudahtt added a commit that referenced this pull request Nov 4, 2019
* Omit MetaMask `extensionId` from site metadata

The site metadata was updated in #7218 to include the extension id of
the extension connecting to MetaMask. This was done to allow external
extensions to connect with MetaMask, so that we could show the id on
the provider approval screen.

Unbeknownst to me at the time, the extension id was being set for all
connections to MetaMask from dapps. The id was set to MetaMask's id,
because the connections are made through MetaMask's contentscript.

This has been updated to only set the id when accepting a connection
from a different extension.

* Fix `siteMetadata` property names

In #7218 a few things were added to the site metadata, so the provider
approval controller was middleware was updated to accept the site
metadata as an object rather than accepting each property as a separate
parameter. Unfortunately we failed to notice that the site name and
icon were named differently in the site metadata than they were in the
provider approval controller, so the names of those properties were
unintentionally changed in the controller state.

The provider approval controller has been updated to restore the
original property names of `siteTitle` and `siteIcon`. An unused prop
that was added to the provider approval page in #7218 has also been
removed.
Gudahtt added a commit that referenced this pull request Nov 13, 2019
External extensions can connect to MetaMask by using `postMessage`
directly. When this is done, the extension id of the sender is
accessible. This extension id has been added to the metadata for the
extension, so that we're able to recognize it as an extension rather
than a dapp.

This was originally added in #7218. The controller with this logic was
replaced in LoginPerSite, so it needed to be re-added.
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