-
Notifications
You must be signed in to change notification settings - Fork 3
Add ticket ownership validation/authentication API middleware #4
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
base: master
Are you sure you want to change the base?
Conversation
66c1943 to
a2f89e6
Compare
|
This is a cool idea! Are you going to bring it over to decred's repo? |
|
Great to see work on this! Just curious
|
a2f89e6 to
2d84864
Compare
The ticket address cannot be signed by the user using his wallet.
User signs a message from his wallet using an address that belongs to the wallet (the ticket reward address). The message the user signs is the current unix timestamp in seconds. |
I guess you mean it cannot be used to sign. Why? Is it because it is a multisig?
I mean how the signature bytes are generated, what algorithm is used? |
Yes, that's what I meant (apologies). And yes, that's why.
https://github.com/decred/dcrwallet/blob/master/wallet/wallet.go#L1428. The message signed ought to be the unix timestamp (in seconds) as at the time of making the request. While the timestamp may be earlier, it cannot be later than the current timestamp. Also, the server rejects timestamps that are up to/more than 30 minutes earlier than the current timestamp. |
|
Where I'm getting at, is that the signature scheme is defined by the hash algo (Blake256 I guess) and signing algo (SignCompact) used. This combination is bound to the name |
Apologies for late reply. I see a valid concern there. It's not common to version auth schemes in that manner. We could use a different scheme name should/when the need arise, such as TicketAuthV2. Your question has even given me further mental clarification. It is unnecessary to mount a new API version endpoint (v3) to allow authentication using this auth scheme. Only need to modify the code to be able to process the new auth scheme on any of the current API version endpoints (v1, v2) if it is supplied. The current scheme supported for API authorization is |
47ed8a9 to
1d4dca5
Compare
Current API routes are mounted on
/api/v1/*and/api/v2/*; and authentication is carried out by providing an API access token in theAuthorizationrequest header field in the format:Authorization: Bearer <api key>This PR adds a new authentication scheme for API endpoints in addition to/without removing the current
Bearerauth scheme. The addedTicketAuthscheme performs ticket-level authentication before executing requested actions. Clients can thus provide authentication information in theAuthorizationrequest header field in the format:Authorization: TicketAuth SignedTimestamp=1564531200, Signature=frJIUN8DYpKDtOLCwo, TicketHash=591b17ed03afc916f274669939924e12ed5ac90d8cc602172fb53237b8a20522Where;
This authorization header format matches that defined in RFC2617. See this SO answer.
User's ticket reward address
A ticket purchased with voting rights shared with a vsp has 2
sstxcommitmentoutputs for receiving staking reward. One of these addresses belongs to the vsp wallet, while the other belongs to the ticket owner's wallet. This second address belonging to the ticket owner is what is used in preparing theSignaturepassed in the authentication header as described above.