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

Restrict KV endpoint to root and node users. #2193

Merged
merged 1 commit into from
Aug 22, 2015

Conversation

mberhault
Copy link
Contributor

Work towards #2089

  • restrict all RPC endpoints to root and node users only.
  • restrict http kv endpoint to root and node users only.
  • sql http endpoint allows all users

Nothing makes use of the rpc.RegisterPublic method yet, but sql will.

func (s *Server) Register(name string, handler func(proto.Message) (proto.Message, error),
// If 'restricted' is true, only system users (RootUser and NodeUser)
// may call this method.
func (s *Server) Register(name string, restricted bool,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than a restricted argument here, how about leaving Register as-is and adding a RegisterPublic method for use by sql.

Copy link
Contributor

Choose a reason for hiding this comment

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

+1

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@petermattis
Copy link
Collaborator

The structure looks fine to me, though I might use the term public instead of restricted.

@@ -388,7 +396,10 @@ func (s *Server) readRequest(codec rpc.ServerCodec) (req rpc.Request, m method,
if ok {
args = reflect.New(m.reqType.Elem()).Interface().(proto.Message)
}
err = codec.ReadRequestBody(args)
if err = codec.ReadRequestBody(args); err != nil || args == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: i'd put the args != nil check before the call to authHook rather than here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@tamird
Copy link
Contributor

tamird commented Aug 20, 2015

LGTM

@mberhault
Copy link
Contributor Author

adjusted for comments. Will ping again when this is ready.

Work towards #2089

* restrict all RPC endpoints to root and node users only.
* restrict http kv endpoint to root and node users only.
* sql http endpoint allows all users

Nothing makes use of the rpc.RegisterPublic method yet, but sql will.
@mberhault mberhault changed the title Do not merge: restrict KV endpoint to root and node users. Restrict KV endpoint to root and node users. Aug 21, 2015
@mberhault
Copy link
Contributor Author

This is ready. Except for addressing the review comments, all other changes are to tests.

@petermattis
Copy link
Collaborator

LGTM, though I didn't examine the test changes/coverage in depth.

if err != nil {
t.Fatalf("%s %s: error building request: %s", method, url, err)
}
if b != nil {
req.Header.Add(util.ContentTypeHeader, util.ProtoContentType)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: any reason not to always do this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's accepted form that the content-type should be set when there is a body. When there is not, it doesn't actually hurt to set it, but there's really no reason to.

@tamird
Copy link
Contributor

tamird commented Aug 21, 2015

LGTM

mberhault added a commit that referenced this pull request Aug 22, 2015
Restrict KV endpoint to root and node users.
@mberhault mberhault merged commit 54f54b4 into master Aug 22, 2015
@mberhault mberhault deleted the marc/restrict_kv_endpoint branch August 22, 2015 16:37
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.

None yet

3 participants