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

SEP-0010: Add back home domain verification with clarity (v3.0.0) #746

Merged
merged 22 commits into from
Nov 9, 2020
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
93c47b3
SEP-0010: Add back home domain verification with clarity (v3.0.0)
leighmcculloch Oct 14, 2020
0c4f269
Make the abstract clearer
leighmcculloch Oct 15, 2020
828b448
Remove ambiguous service term
leighmcculloch Oct 15, 2020
ed16f83
Simplify discussion about servers that do not use stellar.toml for di…
leighmcculloch Oct 17, 2020
55e68ac
Simplify discussion about servers that do not use stellar.toml for di…
leighmcculloch Oct 17, 2020
f666a15
Fix typo
leighmcculloch Oct 17, 2020
ab53bf4
make discovery a clearly separate component
leighmcculloch Oct 17, 2020
aca4d28
Update ecosystem/sep-0010.md
leighmcculloch Oct 17, 2020
4210482
reference domain in discovery flow
leighmcculloch Oct 17, 2020
6c548e8
Fix sentence
leighmcculloch Oct 17, 2020
eb00ba8
Remove ambiguous first step language
leighmcculloch Oct 19, 2020
b22afa9
Remove authenticating for language
leighmcculloch Oct 19, 2020
a235c63
Reference discovery flow in step using signing key
leighmcculloch Oct 21, 2020
bb7700e
Remove longer explanation about how to deal with key rotation that is…
leighmcculloch Oct 23, 2020
5e48d43
Improve description of three components
leighmcculloch Oct 23, 2020
fdcfa0c
Note that the signing key is looked up too
leighmcculloch Oct 23, 2020
b37dac3
Reduce repetition
leighmcculloch Oct 23, 2020
d7fffa3
Update version and details
leighmcculloch Oct 23, 2020
5fb8678
Simplify reptition
leighmcculloch Oct 23, 2020
e732188
Explicitly refer to SEP-1
leighmcculloch Nov 7, 2020
753f5ff
Merge branch 'master' into sep10-v3.0.0-b
leighmcculloch Nov 7, 2020
1d066da
Separate dot point for verification steps
leighmcculloch Nov 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions ecosystem/sep-0010.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Title: Stellar Web Authentication
Author: Sergey Nebolsin <@nebolsin>, Tom Quisel <[email protected]>, Leigh McCulloch <@leighmcculloch>, Jake Urban <[email protected]>
Status: Active
Created: 2018-07-31
Updated: 2020-10-23
Version 2.1.1
Updated: 2020-11-06
Version 3.0.0
```

## Simple Summary
Expand All @@ -18,12 +18,24 @@ This SEP defines the standard way for clients such as wallets or exchanges to cr

This protocol is a variation of mutual challenge-response, which uses Stellar transactions to encode challenges and responses.

The authentication flow is as follows:
It involves three components:
- A domain hosting a [SEP-1 stellar.toml](sep-0001.md) containing a `WEB_AUTH_ENDPOINT` and `SIGNING_KEY`, referred to as the home domain.
- An endpoint providing the GET and POST operations discussed in this document.
- A client who will authenticate using a Stellar account.

The discovery flow is as follows:

1. The client retrieves the `stellar.toml` from the home domain in accordance with [SEP-1 stellar.toml](sep-0001.md).
1. The client looks up the `WEB_AUTH_ENDPOINT` and `SIGNING_KEY` from the `stellar.toml`.

1. The client obtains a unique [`challenge`](#challenge), which is represented as specially formed Stellar transaction
The authentication flow is as follows:
1. The client obtains a unique [`challenge`](#challenge) from the `WEB_AUTH_ENDPOINT`, which is represented as specially formed Stellar transaction
1. The client verifies that the transaction has an invalid sequence number 0. This is extremely important to ensure the transaction isn't malicious.
1. The client verifies that the transaction is signed by the `SIGNING_KEY` specified by the requested service's [SEP-1 stellar.toml](sep-0001.md).
1. The client verifies that the transaction's first operation is a Manage Data operation that has its source account set to the user's account and value set to a nonce value. The client ignores the home domain included.
1. The client verifies that the transaction is signed by the `SIGNING_KEY` obtained through discovery flow.
1. The client verifies that the transaction's first operation is a Manage Data operation that has its:
1. Source account set to the user's account.
1. Key set to `<home domain> auth` where the home domain is the home domain from the discovery flow.
1. Value set to a nonce value.
1. The client verifies that if the transaction has other operations they are Manage Data operations that all have their source accounts set to the the server's account.
1. The client signs the transaction using the secret key(s) of signers for the user's Stellar account
1. The client submits the signed challenge back to the server using [`token`](#token) endpoint
Expand Down Expand Up @@ -69,7 +81,8 @@ In order for browsers-based wallets to validate the CORS headers, as [specified

### Challenge

This endpoint must respond with a Stellar transaction signed by the server that has an invalid sequence number (0) and thus cannot be executed on the Stellar network. The client can then sign the transaction using standard Stellar libraries and submit it to [`token`](#token) endpoint to prove that they control their account. This approach is compatible with hardware wallets such as Ledger. The client must also verify the server's signature to be sure the challenge is signed by the `SIGNING_KEY` from the server's [`stellar.toml`](sep-0001.md).
This endpoint must respond with a Stellar transaction signed by the server that has an invalid sequence number (0) and thus cannot be executed on the Stellar network. The client can then sign the transaction using standard Stellar libraries and submit it to [`token`](#token) endpoint to prove that they control their account. This approach is compatible with hardware wallets such as Ledger. The client must also verify the server's signature to be sure the challenge is signed by the `SIGNING_KEY`, and the home domain in the challenge is the home domain from the discovery flow.


#### Request

Expand All @@ -82,7 +95,7 @@ Request Parameters:
Name | Type | Description
----------|---------------|------------
`account` | `G...` string | The stellar account that the wallet wishes to authenticate with the server
`home_domain` | string | (optional) The [fully qualified domain name](https://en.wikipedia.org/wiki/Fully_qualified_domain_name) of the service requiring authentication. SEP-10 signing servers used to generate tokens for multiple different web services can use this parameter to create valid tokens for each service. If not provided by the client, a default should be used.
`home_domain` | string | (optional) The home domain the client would like to authenticate. Servers that generate tokens for multiple home domains can use this parameter to identify which home domain the client hopes to authenticate. If not provided by the client, the server should assume a default for backwards compatibility with older clients.

Example:

Expand All @@ -100,7 +113,7 @@ On success the endpoint must return `200 OK` HTTP status code and a JSON object
* time bounds: `{min: now(), max: now() + 900 }` (we recommend expiration of 15 minutes to give user time to sign transaction)
* operations:
* `manage_data(source: client_account, key: '<home domain> auth', value: random_nonce())`
* The value of key is the fully qualified domain name of the web service requiring authentication followed by `auth`. It can be at most 64 characters.
* The value of key is the home domain the challenge is authenticating, followed by `auth`. It can be at most 64 characters.
* The value must be 64 bytes long. It contains a 48 byte cryptographic-quality random string encoded using base64 (for a total of 64 bytes after encoding).
* zero or more `manage_data(source: server_account, ...)` reserved for future use
* signature by the service's stellar.toml `SIGNING_KEY`
Expand Down Expand Up @@ -140,6 +153,7 @@ To validate the challenge transaction the following steps are performed by the s
* verify that transaction has time bounds set, and that current time is between the minimum and maximum bounds;
* verify that transaction contains a single [Manage Data](https://www.stellar.org/developers/guides/concepts/list-of-operations.html#manage-data) operation that:
* has a non-null source account
* has the home domain as the key of the operation
* verify that transaction envelope has a correct signature by server's signing key;
* if the operation's source account exists:
* verify that client signatures count is one or more;
Expand Down