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-10: Add multi-sig capabilities #489

Merged
merged 65 commits into from
Jan 29, 2020
Merged
Changes from 14 commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
02ba404
SEP-10: Add multi-sig capabilities
leighmcculloch Dec 4, 2019
703c60d
Tweaking the language
leighmcculloch Dec 5, 2019
3c1b763
Tweak the language
leighmcculloch Dec 5, 2019
c373f23
Simplify
leighmcculloch Dec 5, 2019
02a6706
Add missing word
leighmcculloch Dec 5, 2019
d568dff
Remove asterisk
leighmcculloch Dec 5, 2019
598dc28
Change a word
leighmcculloch Dec 5, 2019
01fec96
Fix typo
leighmcculloch Dec 5, 2019
6ae4f47
Use a better word
leighmcculloch Dec 5, 2019
dfed82d
Use our ubiquitous language
leighmcculloch Dec 5, 2019
d98f82a
Better word selection
leighmcculloch Dec 5, 2019
cda823c
Fix use of plural
leighmcculloch Dec 5, 2019
d91e7ad
Remove detail not required in this paragraph
leighmcculloch Dec 5, 2019
f3b7ca0
Use mirrored language to the auth flow in the achievement section
leighmcculloch Dec 5, 2019
49902d6
Merge branch 'master' into sep10multisig
leighmcculloch Dec 5, 2019
12193a3
Remove statement that is unnecessary
leighmcculloch Dec 5, 2019
e1e07e7
Simplify the `wht` description by not re-mentioning the server key ex…
leighmcculloch Dec 5, 2019
f00d22a
Improve words
leighmcculloch Dec 5, 2019
4f06a28
Say who the servers are
leighmcculloch Dec 5, 2019
e83f645
Remove problematic statement
leighmcculloch Dec 5, 2019
e05e524
Improve words about expiration
leighmcculloch Dec 6, 2019
1b62ec6
Merge branch 'master' into sep10multisig
leighmcculloch Dec 6, 2019
7775d48
Remove jti which was accidentally added back in merge conflict resolu…
leighmcculloch Dec 6, 2019
e1800e4
Add more words about expiration times
leighmcculloch Dec 6, 2019
9b3a450
Fix typo
leighmcculloch Dec 6, 2019
35915d5
Remove extra lines
leighmcculloch Dec 6, 2019
61632ca
Fix words
leighmcculloch Dec 6, 2019
0a48a7e
Make the sentence read better
leighmcculloch Dec 6, 2019
1b21bec
Remove mention of new claims being optional
leighmcculloch Dec 6, 2019
be72fcc
Add support for non-existent accounts, and draw clearer lines around …
leighmcculloch Dec 6, 2019
f6bd403
Fix typo and word
leighmcculloch Dec 6, 2019
cd30bfb
Fix typo and add note about how to validate non-existent signer
leighmcculloch Dec 6, 2019
685ffb9
Make additional claims optional
leighmcculloch Dec 6, 2019
9a96883
boolen => boolean
leighmcculloch Dec 6, 2019
b9da632
Fix grammar
leighmcculloch Dec 6, 2019
185819a
Move paragraph down
leighmcculloch Dec 6, 2019
ead0a2e
Add note pointing out that services can choose to recheck the account…
leighmcculloch Dec 6, 2019
e33fa6f
Tidy text and reduce diff
leighmcculloch Dec 10, 2019
dfbdf32
Keep language consistent with original SEP
leighmcculloch Dec 10, 2019
e5bbe2a
Reduce diff and remove duplicate unnecessary words
leighmcculloch Dec 10, 2019
be9bba6
Align language with original SEP
leighmcculloch Dec 10, 2019
ae80812
Align language with original SEP
leighmcculloch Dec 10, 2019
9317ff8
Fix typo
leighmcculloch Dec 10, 2019
b66c361
Align language with original SEP
leighmcculloch Dec 10, 2019
3334d47
Fix typo
leighmcculloch Dec 10, 2019
25e369e
Add statement about goal
leighmcculloch Dec 10, 2019
413a7c0
Fix typo
leighmcculloch Dec 10, 2019
e7e97dc
Remove recommendations for how to use claims as a method of authoriza…
leighmcculloch Dec 10, 2019
d7f11ab
Reduce diff
leighmcculloch Dec 10, 2019
6c4702c
Merge branch 'master' into sep10multisig
leighmcculloch Dec 19, 2019
6b3415d
Add examples and recommendations for verification, specifically for a…
leighmcculloch Dec 19, 2019
3392edc
Be clear it is verification not validation
leighmcculloch Dec 19, 2019
45747c7
Clearer language
leighmcculloch Dec 19, 2019
8990bfe
Remove repeating words
leighmcculloch Dec 19, 2019
c36c134
Make sentence flow
leighmcculloch Dec 19, 2019
9258e48
Make headings consistent
leighmcculloch Dec 19, 2019
f6c726f
Structure the SEP-24 reference as an example
leighmcculloch Dec 19, 2019
3c9669c
Add missing words
leighmcculloch Dec 19, 2019
8a15ec1
Shorten sentence
leighmcculloch Dec 19, 2019
6cd2c24
Add clarifying words
leighmcculloch Dec 19, 2019
a5f989a
Fix grammar add single quotes
leighmcculloch Dec 20, 2019
7630b1a
Merge branch 'master' into sep10multisig
leighmcculloch Jan 21, 2020
5f74778
Change time bounds for challenge transaction from 5 minutes to 15 min…
leighmcculloch Jan 21, 2020
58aa5e0
Update updated at date to today
leighmcculloch Jan 29, 2020
cc5c6fd
Remove extra word
leighmcculloch Jan 29, 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
46 changes: 33 additions & 13 deletions ecosystem/sep-0010.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
```
SEP: 0010
Title: Stellar Web Authentication
Author: Sergey Nebolsin <[email protected]>, Tom Quisel <[email protected]>
Author: Sergey Nebolsin <[email protected]>, Tom Quisel <[email protected]>, Leigh McCulloch <@leighmcculloch>
Status: Active
Created: 2018-07-31
Updated: 2019-11-22
Version 1.1.1
Updated: 2019-12-04
Version 1.2.1
```

## Simple Summary
Expand All @@ -22,18 +22,23 @@ The authentication flow is as follows:

1. The client obtains a unique [`challenge`](#challenge), 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 signs the transaction using the secret key for the user's Stellar account
1. The client signs the transaction using the secret key(s) of signers of the user's Stellar account
1. The client submits the signed challenge back to the server using [`token`](#token) endpoint
1. If the signature checks out, the server responds with a [JWT](https://jwt.io) that represents the user's session
1. The server gets the signers of the user's account
1. The server verifies the signatures
1. The server verifies the weight provided by the signers meets the required threshold(s)
1. The server responds with a [JWT](https://jwt.io) that represents the user's session
1. Any future calls to the server can be authenticated by including the JWT as a parameter

The flow achieves several things:

* Both client and server part can be implemented using well-established Stellar libraries
* The client can verify that the server holds the secret key to a particular account
* The server can verify that the client holds the secret key to their account
* The client is able to prove their identity using a Ledger or other hardware wallet as well as by having direct access to the secret key
* The server can chose its own timeout for the user's session
* The client can verify that the server holds the secret key to a particular public key
* The server can verify that the client holds the secret key(s) of signers of the user's Stellar account
* The client is able to prove their identity using a Ledger or other hardware wallet as well as by having direct access to the secret key(s)
* The server can choose its own timeout for the user's session
* The server can choose the required threshold(s) a user needs on the account
* Other servers can choose the required threshold(s) a user needs on the account for specific functionality
leighmcculloch marked this conversation as resolved.
Show resolved Hide resolved

## Authentication Endpoint

Expand All @@ -54,7 +59,7 @@ 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 can 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 and multiple signatures can be included for accounts with multiple signers. The client can 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).

#### Request

Expand Down Expand Up @@ -120,19 +125,28 @@ To validate the challenge transaction the following steps are performed by the s
* decode the received input as a base64-urlencoded XDR representation of Stellar transaction envelope;
* verify that transaction source account is equal to the server's signing key;
* 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 and it's source account is not null;
* verify that transaction envelope has a correct signature by server's signing key;
* verify that transaction envelope has a correct signature by the operation's source account;
* verify that transaction contains a single [Manage Data](https://www.stellar.org/developers/guides/concepts/list-of-operations.html#manage-data) operation and its source account is not null;
* verify that transaction sequenceNumber is equal to zero;
* verify that transaction envelope has a correct signature by server's signing key;
* verify that client signatures on the transactions are signers of the operations source account;
* verify that client signatures are correct;
* verify that client signatures provide weight that meets the required threshold(s);
* use operations's source account to determine the authenticating client and perform any additional service-specific validations.

When determining the weight of the signers the server's signer should be excluded, even if it is a signer on the account. In most cases the server should verify that the signers meet all thresholds of the account by checking that the sum of the weights is equal or greater to the low, mid and high thresholds, and fail to issue a JWT if all thresholds are not met. Some servers may have use cases to issue JWTs for less than all thresholds.
leighmcculloch marked this conversation as resolved.
Show resolved Hide resolved

Upon successful validation service responds with a session JWT, containing the following claims:

* `iss` (the principal that issued a token, [RFC7519, Section 4.1.1](https://tools.ietf.org/html/rfc7519#section-4.1.1)) — a [Uniform Resource Identifier (URI)] for the issuer (`https://example.com` or `https://example.com/G...`)
* `sub` (the principal that is the subject of the JWT, [RFC7519, Section 4.1.2](https://tools.ietf.org/html/rfc7519#section-4.1.2)) — the public key of the authenticating Stellar account (`G...`)
* `iat` (the time at which the JWT was issued [RFC7519, Section 4.1.6](https://tools.ietf.org/html/rfc7519#section-4.1.6)) — current timestamp (`1530644093`)
* `exp` (the expiration time on or after which the JWT must not be accepted for processing, [RFC7519, Section 4.1.4](https://tools.ietf.org/html/rfc7519#section-4.1.4)) — a server can pick its own expiration period for the token, however 24 hours is recommended (`1530730493`)
* `jti` (the unique identifier for the JWT, [RFC7519, Section 4.1.7](https://tools.ietf.org/html/rfc7519#section-4.1.7)) — hex-encoded hash of the challenge transaction (`f0e754c6ab988eb5fb2811c2cacc4d3d2aa4334763b8df7285ef341921e2530a`)
leighmcculloch marked this conversation as resolved.
Show resolved Hide resolved
* `thr`
* `low` — low threshold of the account
* `med` — medium threshold of the account
* `high` — high threshold of the account
* `wht` — weight of the signers who signed the challenge transaction, excluding the weight of the server signer if it is also a signer of the account
leighmcculloch marked this conversation as resolved.
Show resolved Hide resolved

The JWT may contain other claims specific to your application, see [RFC7519].

Expand Down Expand Up @@ -188,6 +202,12 @@ Every other HTTP status code will be considered an error. For example:
}
```

## Validating the JWT

Services that use the JWT as proof the user meets a threshold of control of a Stellar account need to validate the JWT. General [JWT best practices](#jwt-best-practices) should be followed for validating the claims within the header and payload. If the JWT contains threshold (`thr`) and weight (`wht`) claims the service should check that the threshold required by that service is met.

Some versions of SEP-10 did not include the `thr` and `wht` and if the claims are not present the service can assume all thresholds were met.
leighmcculloch marked this conversation as resolved.
Show resolved Hide resolved

## A convention for signatures

Signatures in Stellar involve both the secret key of the signer and the passphrase of the network. SEP-10 clients and servers must use the following convention when deciding what network passphrase to use for signing and verifying signatures in SEP-10:
Expand Down