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

Update SEP-10 Utils #568

Merged
merged 3 commits into from
Aug 28, 2020
Merged

Update SEP-10 Utils #568

merged 3 commits into from
Aug 28, 2020

Conversation

JakeUrban
Copy link
Contributor

@JakeUrban JakeUrban commented Aug 27, 2020

resolves stellar/integration-meta#193

Adds the optional homeDomain argument to buildChallengeTx() and readChallengeTx().

The change to buildChallengeTx() will allow anchors to build challenge transactions with their service's home domain included in Manage Data operation.

Note that this is not the home domain of the server that returns and verifies the challenge transaction. The home domain referenced in the changes here is in reference to the home domain that hosts the service's stellar.toml file.

The change to readChallengeTx() will allow clients to verify that the challenge transaction received includes the home domain of the service hosting the same TOML file used to fetch the endpoint for the authentication request. Anchors can also verify this field to ensure clients do not send challenges received from other anchors.

These SDK changes do not guarantee the challenge transaction originated from the same service that hosts the TOML file used. For that, clients must verify the following:

  • the home domain of the service that hosts the TOML file used is included in the challenge's Manage Data operation
    • This is enabled with the changes introduced in this PR
  • the challenge is signed by the SIGNING_KEY listed in the same stellar.toml file

@JakeUrban JakeUrban marked this pull request as draft August 27, 2020 21:01
const challenge = StellarSdk.Utils.buildChallengeTx(
keypair,
"GBDIT5GUJ7R5BXO3GJHFXJ6AZ5UQK6MNOIDMPQUSMXLIHTUNR2Q5CFNF",
null,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The one downside to this approach is that I can't make anchorName optional, since networkPassphrase has no default. This may mean that the best approach is having two different functions, one for each SEP-10 protocol major version.

@JakeUrban JakeUrban requested review from marcelosalloum, abuiles and ire-and-curses and removed request for abuiles and marcelosalloum August 27, 2020 22:29
@JakeUrban
Copy link
Contributor Author

@abuiles @marcelosalloum for reference

@JakeUrban JakeUrban requested review from tamirms and removed request for ire-and-curses August 27, 2020 22:55
src/utils.ts Outdated
// fully qualified domain name of the web service requiring authentication
let manageDataKey;
if (homeDomain) {
const homeDomainKeyValue = homeDomain.startsWith("https://")
Copy link
Contributor

Choose a reason for hiding this comment

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

what if it starts with "http://" ?

Copy link
Contributor

Choose a reason for hiding this comment

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

nevermind, I just checked and it seems a toml must be hosted via ssl

Copy link
Contributor

Choose a reason for hiding this comment

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

I think it might be better to be strict and only accept full https urls

src/utils.ts Outdated
@@ -185,6 +207,18 @@ export namespace Utils {
);
}

// verify homeDomain
if (homeDomain) {
const homeDomainKeyValue = homeDomain.startsWith("https://")
Copy link
Contributor

Choose a reason for hiding this comment

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

there seems to be some inconsistency between the code which extracts the home domain value here and the code in buildChallengeTx()

@JakeUrban
Copy link
Contributor Author

JakeUrban commented Aug 28, 2020

@tamirms thanks for your comments, after the Python SDK was released today I decided to mirror that approach. It replaces the anchorName parameter with homeDomain, so developers don't have to pass null to an unused anchorName parameter.

See the python SDK functions here.

The optional homeDomain parameter was added to readChallengeTx(), which will check that the homeDomain string matches the Manage Data key value.

@JakeUrban JakeUrban marked this pull request as ready for review August 28, 2020 16:15
Copy link
Contributor

@tamirms tamirms left a comment

Choose a reason for hiding this comment

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

👍

@JakeUrban JakeUrban merged commit 91140df into stellar:master Aug 28, 2020
@JakeUrban JakeUrban deleted the sep10-patch branch August 28, 2020 17:17
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.

None yet

2 participants