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 49 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
40 changes: 32 additions & 8 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-12-02
Version 1.2.0
Updated: 2019-12-04
Version 1.3.0
```

## 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 for the user's Stellar account
1. The client submits the signed challenge back to the server using [`token`](#token) endpoint
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), if any
Copy link
Contributor

Choose a reason for hiding this comment

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

What is meaning of required thresholds in this context?

Copy link
Member Author

Choose a reason for hiding this comment

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

Any threshold the implementer wants the client to meet on the account. In many cases and for simplicity an implementer should probably just confirm that the signatures meet all thresholds (low, med, high) on an account to ensure the user completely holds an account in the same way they do if they have the default master key set as a signer.

An implementer can change this however they need for their specific application, requiring any lower threshold or no threshold. See this section:

The verification process goal is to confirm that a user holds an account. Depending on your application this may mean complete signing authority, some threshold of control, or being a signer of the account.
A server that needs to verify a user has complete signing authority of an account should verify that the weight of the client signatures meet all thresholds of the account. It should do this by checking that the sum of the weights is equal or greater to all the thresholds: low, mid and high. The server should only issue a JWT if all thresholds are met. When determining the weight of the client signatures the server's signature should be explicitly excluded as it may be a signer on the account and a server verifying authentication should not help the client authenticate.
A server may choose to issue JWTs for less than all thresholds and based on any other application specific logic.

1. If the signature checks out, 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 verify that the client holds the secret key(s) to signers of 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(s)
* The server can choose its own timeout for the user's session
* The server can choose required threshold(s) that the user needs on the account, if any
Copy link
Contributor

Choose a reason for hiding this comment

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

Why would an authentication server choose a threshold? It doesn't know what the token will be used for. In my view of things, these servers produce tokens that other servers use for authorization (based on their own rules).

It seems like this SEP is intending for every application server to be producing its own tokens based on its own authorization rule set. I don't agree with that approach, it seems like a single authentication server producing tokens (with claims) for all application servers to use, is the correct approach.

Copy link
Member Author

Choose a reason for hiding this comment

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

This SEP is leaving that in the implementers control. A server can implement a verification of required thresholds to meet its definition of a user "holding an account", and a server can add any additional claims to the JWT if it wishes to provide authentication for multiple other services where varying levels of threshold are required.

* The server can choose to include other application specific claims

## Authentication Endpoint

Expand Down Expand Up @@ -122,16 +127,31 @@ 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 and its 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;
* if the operations source account exists:
leighmcculloch marked this conversation as resolved.
Show resolved Hide resolved
* verify that client signatures count is one or more;
* verify that client signatures on the transaction 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), if any;
* if the operations source account does not exist:
leighmcculloch marked this conversation as resolved.
Show resolved Hide resolved
* verify that client signature count is one;
* verify that client signature is correct for the master key of the account address;
* verify that transaction sequenceNumber is equal to zero;
* use operations's source account to determine the authenticating client and perform any additional service-specific validations.

The verification process goal is to confirm that a user holds an account. Depending on your application this may mean complete signing authority, some threshold of control, or being a signer of the account.

A server that needs to verify a user has complete signing authority of an account should verify that the weight of the client signatures meet all thresholds of the account. It should do this by checking that the sum of the weights is equal or greater to all the thresholds: low, mid and high. The server should only issue a JWT if all thresholds are met. When determining the weight of the client signatures the server's signature should be explicitly excluded as it may be a signer on the account and a server verifying authentication should not help the client authenticate.

A server may choose to issue JWTs for less than all thresholds and based on any other application specific logic.

A server that needs to support validating accounts that do not exist can require a signature of the master key of the account address.

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`)
* `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 (`1530730493`)

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

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

## JWT Expiration

Servers should select an expiration time for the JWT that is appropriate for the assumptions and risk of the interactions a user can perform with it. A user may be in control of an account at the time the JWT is issued but they may lose control of the account through a change in signers. Expiration times that are too long increase the risk that control on the account has changed. Expiration times that are too short increase the number of times authentication must reoccur, and a user using a hardware signing device or who must complete a complex signing process could have a poor user experience.

## 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