Skip to content

ZOOKEEPER-2649 - Add more session and authentication information to S…#1498

Closed
Ghatage wants to merge 4 commits intoapache:masterfrom
Ghatage:ZOOKEEPER-2649
Closed

ZOOKEEPER-2649 - Add more session and authentication information to S…#1498
Ghatage wants to merge 4 commits intoapache:masterfrom
Ghatage:ZOOKEEPER-2649

Conversation

@Ghatage
Copy link
Copy Markdown
Contributor

@Ghatage Ghatage commented Oct 12, 2020

…ASL success and failure logs.

Another one from the backlogs - created in 2016, no activity since 6 months.

JIRA: https://issues.apache.org/jira/browse/ZOOKEEPER-2649

cc @eolivelli

@Ghatage
Copy link
Copy Markdown
Contributor Author

Ghatage commented Oct 12, 2020

Needs more work, nvm. Will close, rework and open a new PR later.

@Ghatage Ghatage closed this Oct 12, 2020
if (saslServer.isComplete()) {
String authorizationID = saslServer.getAuthorizationID();
LOG.info("adding SASL authorization for authorizationID: {}", authorizationID);
LOG.info("Session 0x{}: adding SASL authorization for authorizationID: {}",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

+1.

I'd like to have this in the tree, and was about to submit a patch with something like this.

(Arguably, it'd be sufficient to augment logging here and not on the other path of ZooKeeperServer, as the "pluggable" authentication providers can and should do their own, "domain-specific," logging.)

@Ghatage: are you planning to give this another go?

Comment on lines +1602 to +1606
ZooKeeperSaslServer saslServer = cnxn.zooKeeperSaslServer;
LOG.debug("Authentication succeeded for scheme: {}", scheme);
LOG.info("auth success {}", cnxn.getRemoteSocketAddress());
LOG.info("Session 0x{}: auth success for authorizationID={}/{}",
Long.toHexString(cnxn.getSessionId()), saslServer.getAuthorizationID(),
cnxn.getRemoteSocketAddress());
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is the "traditional" authentication path, used by providers others than SASL. Unless I am missing something, saslServer is likely to be NULL here.

(I suppose this is the reason for your "Needs more work" comment.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's right @ztzg.
I was just helping clear out the backlog when I took this up but I think I'll need to add in more code so took a breather on this.
I would still like to give it a shot till the weekend if you don't mind. Will tag you for updated codes' review :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sure; no hurry/pressure. Was just checking as I was working in the same area…

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@ztzg I added some code to protect the use of sasl in the log statement only if its not null.
Not sure if that is sufficient / appropriate.. please advise!

Copy link
Copy Markdown
Contributor

@ztzg ztzg Oct 19, 2020

Choose a reason for hiding this comment

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

Hi @Ghatage,

No, I don't think that's what we want—sorry for not being clearer in my previous comment.

This is the code path where "traditional" auth packets are being handled. While it is technically possible to send a sasl auth packet to a server, the handleAuthentication method of SASLAuthenticationProvider always returns AUTHFAILED. So you'll never enter that block in response to SASL auth.

Now, while I think it would be good to add at least the sessionId and scheme to that message, adding the "user name" corresponding to a traditional AuthenticationProvider is quite a bit more complicated—and doing it "very cleanly" would arguably require incompatible infrastructure changes.

(For example, DigestAuthenticationProvider can add up to two Ids to a connection, and the existing interface does not allow it to return them; you'd have to "diff" the before and after Id sets to know what has changed.)

So I'm not sure it's worth the effort, given that everybody is moving towards SASL and/or X509 anyway. And even if one wants to keep using a traditional provider, it is usually more useful to let it do its own (domain-specific) logging.

In conclusion: I'd just add the sessionId and scheme there, and ignore the actual Id(s).

Hope this helps, -D

Cc: @eolivelli & @symat.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In conclusion: I'd just add the sessionId and scheme there, and ignore the actual Id(s).

make sense to me.
(for SASL I think we already have log outputs about the authenticated principal names)

@Ghatage Ghatage reopened this Oct 17, 2020
@Ghatage
Copy link
Copy Markdown
Contributor Author

Ghatage commented Oct 22, 2020

Thank you for the detailed explanation, @ztzg!
I've made the recommended changes, PTAL and let me know if that's appropriate.

cc @eolivelli, @symat

if (authReturn == KeeperException.Code.OK) {
LOG.debug("Authentication succeeded for scheme: {}", scheme);
LOG.info("auth success {}", cnxn.getRemoteSocketAddress());
ZooKeeperSaslServer saslServer = cnxn.zooKeeperSaslServer;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Almost… but I'm afraid you still have a leftover saslServer variable here :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sorry about that! Fixed it now.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No problem! LGTM.

@Ghatage
Copy link
Copy Markdown
Contributor Author

Ghatage commented Oct 22, 2020

@eolivelli @symat PTAL

Copy link
Copy Markdown
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Contributor

@symat symat left a comment

Choose a reason for hiding this comment

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

LGTM, +1

@ztzg ztzg closed this in 8853b33 Oct 28, 2020
@ztzg
Copy link
Copy Markdown
Contributor

ztzg commented Oct 28, 2020

Merged into master. Thank you for this and #1497, @Ghatage!

@Ghatage
Copy link
Copy Markdown
Contributor Author

Ghatage commented Oct 28, 2020

Thanks for the guidance and accepting my contributions @ztzg and @symat.
I absolutely love the project and hope to make more contributions going forward!

RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Aug 31, 2022
…SL success and failure logs

…ASL success and failure logs.

Another one from the backlogs - created in 2016, no activity since 6 months.

JIRA: https://issues.apache.org/jira/browse/ZOOKEEPER-2649

cc eolivelli

Author: Ghatage <ghatageanup@gmail.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>, Damien Diederen <ddiederen@apache.org>

Closes apache#1498 from Ghatage/ZOOKEEPER-2649
RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Aug 31, 2022
…SL success and failure logs

…ASL success and failure logs.

Another one from the backlogs - created in 2016, no activity since 6 months.

JIRA: https://issues.apache.org/jira/browse/ZOOKEEPER-2649

cc eolivelli

Author: Ghatage <ghatageanup@gmail.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>, Damien Diederen <ddiederen@apache.org>

Closes apache#1498 from Ghatage/ZOOKEEPER-2649
RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Aug 31, 2022
…SL success and failure logs

…ASL success and failure logs.

Another one from the backlogs - created in 2016, no activity since 6 months.

JIRA: https://issues.apache.org/jira/browse/ZOOKEEPER-2649

cc eolivelli

Author: Ghatage <ghatageanup@gmail.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>, Damien Diederen <ddiederen@apache.org>

Closes apache#1498 from Ghatage/ZOOKEEPER-2649
RokLenarcic pushed a commit to RokLenarcic/zookeeper that referenced this pull request Sep 3, 2022
…SL success and failure logs

…ASL success and failure logs.

Another one from the backlogs - created in 2016, no activity since 6 months.

JIRA: https://issues.apache.org/jira/browse/ZOOKEEPER-2649

cc eolivelli

Author: Ghatage <ghatageanup@gmail.com>

Reviewers: Enrico Olivelli <eolivelli@apache.org>, Mate Szalay-Beko <symat@apache.org>, Damien Diederen <ddiederen@apache.org>

Closes apache#1498 from Ghatage/ZOOKEEPER-2649
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.

4 participants