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

Implement SASL reader #170

Closed
wants to merge 9 commits into from
Closed

Implement SASL reader #170

wants to merge 9 commits into from

Conversation

dtaniwaki
Copy link
Contributor

@dtaniwaki dtaniwaki commented Feb 19, 2019

I made RPC writing and reading interface and implemented SASL reader which is supposed to be used when a GSS API server responded with TOKEN auth and the QOP is auth-conf or auth-int.

I tried all the following patterns of qop config in core-site.xml and all of them work fine with this change.

  • hadoop.rpc.protection : authentication
  • hadoop.rpc.protection : integrity
  • hadoop.rpc.protection : privacy

I didn't implement SaslRpcWriter as it requires a client to choose QOP and a lot of changes around the command line tool is necessary. I will start to implement it once this PR gets merged.

Solves: #144

@dtaniwaki
Copy link
Contributor Author

I think the CI failure is caused by a race condition.

@colinmarc
Copy link
Owner

Hi @dtaniwaki,

This looks great, but I'm a bit leery of merging it without any tests. Could you please add some?

I'd add another whole branch here, to run the test suite with those settings enabled.

@dtaniwaki
Copy link
Contributor Author

@colinmarc I added RPC protection environment matrix. Is it what you meant?
I think the CI failure is not related to the change of this PR because it's error on appending.

Makefile Outdated
@@ -9,6 +9,7 @@ PROTO_MAPPING = MSecurity.proto=github.com/colinmarc/hdfs/v2/internal/protocol/h
TRAVIS_TAG ?= $(shell git rev-parse HEAD)
ARCH = $(shell go env GOOS)-$(shell go env GOARCH)
RELEASE_NAME = gohdfs-$(TRAVIS_TAG)-$(ARCH)
_CLIENT = $(shell kubectl get pods -l app=hdfs-client,release=my-hdfs -o name | cut -d/ -f 2)
Copy link
Owner

@colinmarc colinmarc Feb 23, 2019

Choose a reason for hiding this comment

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

I think this snuck in from your local testing environment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oops! Thank you for pointing it out!

Copy link
Owner

@colinmarc colinmarc left a comment

Choose a reason for hiding this comment

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

This is looking pretty good - just some nitpicks in there.


const (
// Authentication - Establishes mutual authentication between the client and the server
Authentication = QualityOfProtection("auth")
Copy link
Owner

Choose a reason for hiding this comment

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

Just make these string constants, I think.

tokenChallenge := TokenChallenge{}
matched := challengeRegexp.FindAllSubmatch(auth.Challenge, -1)
if matched == nil {
return nil, errors.New("aaaa")
Copy link
Owner

Choose a reason for hiding this comment

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

You need to pass the error up here (with a more informative message ;))

Copy link
Contributor Author

@dtaniwaki dtaniwaki Feb 23, 2019

Choose a reason for hiding this comment

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

I don’t know what happened with this error message :P I’ll fix it.

if err != nil {
return err
}

// Read the final response. If it's a SUCCESS, then we're done here.
_, err = c.readSaslResponse(hadoop.RpcSaslProto_SUCCESS)
if err != nil {
Copy link
Owner

Choose a reason for hiding this comment

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

This block is redundant.

if err != nil {
return err
}
if challenge.QOP == Privacy || challenge.QOP == Integrity {
Copy link
Owner

Choose a reason for hiding this comment

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

We should error on a QOP we can't handle.

// To check interface validity
var rpcWriter RpcWriter = &BasicRpcWriter{}
var rpcReader RpcReader = &BasicRpcReader{}
var saslRpcReader RpcReader = &SaslRpcReader{}
Copy link
Owner

Choose a reason for hiding this comment

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

This isn't necessary - the interface validity is checked elsewhere in the code.

var saslRpcReader RpcReader = &SaslRpcReader{}

// RpcWriter is an interface for sending RPC payload
type RpcWriter interface {
Copy link
Owner

Choose a reason for hiding this comment

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

I think this is basically, right, but can you call it 'Transport'? There's a good chance the Transport should track the request sequence number, too.

Copy link
Contributor Author

@dtaniwaki dtaniwaki Feb 23, 2019

Choose a reason for hiding this comment

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

Could you tell me what is supposed to call Transport in detail?
I guess your comment above is more than just renaming the RpcWriter interface.

type BasicRpcReader struct {
}

// SaslRpcReader is a RPC reader which wrap payload with SASL
Copy link
Owner

Choose a reason for hiding this comment

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

Sorry for being picky, but can you change all these comments to be complete sentences?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will try it.

@dtaniwaki
Copy link
Contributor Author

@colinmarc I updated the PR based on your review comment. Would you check it again? I will squash the commits after review if necessary.

@jaguarx
Copy link

jaguarx commented Jun 10, 2019

Hi
Any chance to merge this into the repo? It seems fix the issue of accessing cluster with qos-conf.

Best!
Jaguar

@mikenolt
Copy link

I am using kerberos and also hit the unexpected sequence number issue so could use this. Any ETA?

@mikenolt
Copy link

@colinmarc @dtaniwaki - Are there any plans for merging this? The partial workaround provided in issue #144 worked so I know I need this functionality to get things fully working.

Thanks

@colinmarc
Copy link
Owner

colinmarc commented Nov 24, 2019

Merged in 1c841f7. Thanks for your help, and sorry for the delay!

@colinmarc colinmarc closed this Nov 24, 2019
@dtaniwaki dtaniwaki deleted the sasl branch August 4, 2020 05:47
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

4 participants