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

Create limited RPC user. #363

Merged
merged 1 commit into from
Apr 13, 2015
Merged

Conversation

aakselrod
Copy link
Contributor

The limited user is specified with the --rpclimituser and
--rpclimitpass options (or the equivalent in the config file).
The config struct and loadConfig() are updated to take the
new options into account. The limited user can have neither
the same username nor the same password as the admin user.

The package-level rpcLimit map in rpcserver.go specifies
the RPC commands accessible by limited users. This map
includes both HTTP/S and websocket commands.

The checkAuth function gets a new return parameter to
signify whether the user is authorized to change server
state. The result is passed to the jsonRPCRead function and
to the WebsocketHandler function in rpcwebsocket.go.

The wsClient struct is updated with an "isAdmin" field
signifying that the client is authorized to change server
state, written by WebsocketHandler and handleMessage.
The handleMessage function also checks the field to
allow or disallow an RPC call.

The following documentation files are updated:

  • doc.go
  • sample-btcd.conf
  • docs/README.md
  • docs/json_rpc_api.md
  • docs/configure_rpc_server_listen_interfaces.md

@davecgh
Copy link
Member

davecgh commented Apr 1, 2015

I haven't reviewed the code yet, but I did notice there are several documentation updates that will be needed that I don't see here:

"getrawmempool": struct{}{},
"getrawtransaction": struct{}{},
"gettxout": struct{}{},
"ping": struct{}{},
Copy link
Member

Choose a reason for hiding this comment

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

This one isn't read-only.

@davecgh
Copy link
Member

davecgh commented Apr 2, 2015

@aakselrod: Thanks for the PR. It looks good overall. I think we'll want to debate the specific command list. I think ping is uncontested since it clearly isn't a read-only command, but I know @dajohi has mentioned some others which are technically read-only, but might be worth leaving out to enhance privacy.

@aakselrod aakselrod force-pushed the readonly-rpc branch 2 times, most recently from 48eb5ec to f3f129e Compare April 2, 2015 17:14
@davecgh davecgh changed the title Create RPC read-only user. Create limited RPC user. Apr 13, 2015
}
if cfg.RPCLimitUser != "" && cfg.RPCLimitPass != "" {
login := cfg.RPCLimitUser + ":" + cfg.RPCLimitPass
roauth := "Basic " + base64.StdEncoding.EncodeToString([]byte(login))
Copy link
Member

Choose a reason for hiding this comment

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

Not a big deal, but roauth should probably just be auth here as well since it's not read-only anymore.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to auth from roauth.

@davecgh
Copy link
Member

davecgh commented Apr 13, 2015

Alright, everything looks good! If you can squash/rebase it, I'll merge it.

@aakselrod aakselrod force-pushed the readonly-rpc branch 2 times, most recently from 9607cbe to 1f2fdf9 Compare April 13, 2015 17:44
The limited user is specified with the --rpclimituser and
--rpclimitpass options (or the equivalent in the config file).
The config struct and loadConfig() are updated to take the
new options into account. The limited user can have neither
the same username nor the same password as the admin user.

The package-level rpcLimit map in rpcserver.go specifies
the RPC commands accessible by limited users. This map
includes both HTTP/S and websocket commands.

The checkAuth function gets a new return parameter to
signify whether the user is authorized to change server
state. The result is passed to the jsonRPCRead function and
to the WebsocketHandler function in rpcwebsocket.go.

The wsClient struct is updated with an "isAdmin" field
signifying that the client is authorized to change server
state, written by WebsocketHandler and handleMessage.
The handleMessage function also checks the field to
allow or disallow an RPC call.

The following documentation files are updated:
- doc.go
- sample-btcd.conf
- docs/README.md
- docs/json_rpc_api.md
- docs/configure_rpc_server_listen_interfaces.md
@davecgh
Copy link
Member

davecgh commented Apr 13, 2015

I've tested the following:

  • Specifying the same username for limited/admin user causes an error on start as expected
  • Specifying the same password for limited/admin user causes an error on start as expected
  • The RPC server is disabled if neither set of credentials is provided
  • The RPC server is enabled if only admin credentials are provided
  • The RPC server is enabled if only limited credentials are provided
  • The RPC server is enabled if both sets of credentials are provided
  • Attempting to issue admin RPC commands against the limited credentials returns an error as expected
  • Attempting to mix/match usernames and passwords fails credential checks as intended

@conformal-deploy conformal-deploy merged commit 4a1445a into btcsuite:master Apr 13, 2015
@aakselrod aakselrod deleted the readonly-rpc branch April 13, 2015 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants