decred / dcrtime

Decred anchored timestamp client, proxy, and server.
ISC License
28 stars 23 forks source link

Feature/dcrtime 29 add privileged get balance call #52

Closed sefbkn closed 4 years ago

sefbkn commented 5 years ago

Add command line flags to dcrtime to support retrieving wallet balance. Add configuration to dcrtime & dcrtimed for authentication, in addition to command line flags.

Example usage

dcrtimed --apitoken=demo dcrtime --balance --apitoken=demo

Edit: Closes issue #29

dajohi commented 5 years ago

I prefer just to use some privileged API secret token versus creating usernames and passwords.

marcopeereboom commented 5 years ago

I prefer just to use some privileged API secret token versus creating usernames and passwords.

20:15:26 <dhill> time.decred.org/api/balance?token=kljasflkjaflkjahsfasfa                                                                      
20:16:29 <marco> just a secret token?                                                                                                          
20:16:58 <marco> i am ok with that too                                                                                                         
20:16:25 <dhill> well, a []string of them                                                                                                      
20:17:18 <marco> what do you mean?                                                                                                             
20:17:05 <dhill>  APIToken []string `long:apitoken`                                                                                            
20:17:20 <dhill> ./dcrtimed --apitoken=token1 --apitoken=tokenformarco --apitoken=tokenfordhill                   
dajohi commented 5 years ago

I prefer tokens.

type config struct {
   APIToken []string `long:"apitoken" description:"Privileged API Access Token"`
}

Then: ./dcrtimed --apitoken=124lkjh21l4kh1242142 --apitoken=19u41lb41n243lk123

then a user would visit:

https://time.decred.org/api/v1/balance?apitoken=124lkjh21l4kh1242142

sefbkn commented 5 years ago

@marcopeereboom Wide code is no more (except long method signatures and descriptions of config options).

@dajohi The user can now hit this at the following endpoint. Only reason I did not add the /api prefix in the routes is the rest of the URLs don't follow that convention in the daemon. GET /v1/balance?apitoken=<token>

or by using the dcrtime cli as requested in the issue description dcrtime --balance --apitoken=<token>