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

[authentication] Validate tokens for binary connections #6233

Merged
merged 1 commit into from
Mar 18, 2020

Conversation

addisonj
Copy link
Contributor

@addisonj addisonj commented Feb 5, 2020

Motivation

Currently, binary connects aren't checked to see if they provide a
token.

This results in a NPE in the JWT validation as well as a whole bunch of
log spam.

Modifications

By explicitly checking for a null/empty token here, we can
avoid some exceptions and clean up log spam.

Verifying this change

  • Make sure that the change passes the CI checks.

This change is a trivial rework / code cleanup without any test coverage.

Does this pull request potentially affect one of the following parts:

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): no
  • The public API: no
  • The schema: n
  • The default values of configurations: n
  • The wire protocol: n
  • The rest endpoints: n
  • The admin cli options: n
  • Anything that affects deployment:n

Documentation

  • Does this pull request introduce a new feature? n
  • If yes, how is the feature documented? not applicable
  • If a feature is not applicable for documentation, explain why?
  • If a feature is not documented yet in this PR, please create a followup issue for adding the documentation

@addisonj addisonj closed this Feb 6, 2020
@addisonj addisonj reopened this Feb 6, 2020
Copy link
Member

@sijie sijie left a comment

Choose a reason for hiding this comment

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

Interestingly, it seems that we don't have a test to catch that. @addisonj it is possible to add a test case for this.

@sijie sijie added this to the 2.6.0 milestone Feb 7, 2020
@sijie sijie added release/2.5.1 type/bug The PR fixed a bug or issue reported a bug labels Feb 7, 2020
@merlimat
Copy link
Contributor

merlimat commented Feb 7, 2020

Currently, binary connects aren't checked to see if they provide a token.

So it results in NPE, though the client is still not being allowed in, right?

@addisonj
Copy link
Contributor Author

addisonj commented Feb 7, 2020 via email

Currently, binary connects aren't checked to see if they provide a
token.

This results in a NPE in the JWT validation as well as a whole bunch of
log spam. By explictly checking for a null/empty token here, we can
avoid some exceptions and clean up log spam.
@merlimat
Copy link
Contributor

merlimat commented Feb 7, 2020

I don't believe this will actually makes the logs be less
noisy as it still throws an exception that is logged,

It should, since we don't print the full stack trace in case of an AuthenticationException (since it's a "known" failure mode).

@merlimat
Copy link
Contributor

merlimat commented Feb 7, 2020

Interestingly, it seems that we don't have a test to catch that. @addisonj it is possible to add a test case for this.

It might be tricky to test since the connection gets rejected. Maybe a way would be to check the exception type when creating a producers (eg: AuthenticationError vs Timeout)

@addisonj
Copy link
Contributor Author

addisonj commented Feb 7, 2020

@merlimat it still results in an AuthenticationError because it gets caught by this try/catch here:

throw new AuthenticationException("Failed to authentication token: " + e.getMessage());

But if that is how it should behave, that would be great and much less noisy

@sijie
Copy link
Member

sijie commented Feb 12, 2020

@merlimat can you check the last comment?

@sijie
Copy link
Member

sijie commented Mar 18, 2020

@merlimat @addisonj any thoughts about this?

@addisonj
Copy link
Contributor Author

@sijie I just say we merge it, it should at least give a more clear error message, but we can always clean up the logs more later

@sijie sijie merged commit 00ce81f into apache:master Mar 18, 2020
tuteng pushed a commit to AmateurEvents/pulsar that referenced this pull request Mar 21, 2020
Currently, binary connects aren't checked to see if they provide a
token.

This results in a NPE in the JWT validation as well as a whole bunch of
log spam. By explictly checking for a null/empty token here, we can
avoid some exceptions and clean up log spam.

Co-authored-by: Addison Higham <ahigham@instructure.com>
(cherry picked from commit 00ce81f)
tuteng pushed a commit that referenced this pull request Apr 13, 2020
Currently, binary connects aren't checked to see if they provide a
token.

This results in a NPE in the JWT validation as well as a whole bunch of
log spam. By explictly checking for a null/empty token here, we can
avoid some exceptions and clean up log spam.

Co-authored-by: Addison Higham <ahigham@instructure.com>
(cherry picked from commit 00ce81f)
jiazhai pushed a commit to jiazhai/pulsar that referenced this pull request May 18, 2020
Currently, binary connects aren't checked to see if they provide a
token.

This results in a NPE in the JWT validation as well as a whole bunch of
log spam. By explictly checking for a null/empty token here, we can
avoid some exceptions and clean up log spam.

Co-authored-by: Addison Higham <ahigham@instructure.com>(cherry picked from commit 00ce81f)
huangdx0726 pushed a commit to huangdx0726/pulsar that referenced this pull request Aug 24, 2020
Currently, binary connects aren't checked to see if they provide a
token.

This results in a NPE in the JWT validation as well as a whole bunch of
log spam. By explictly checking for a null/empty token here, we can
avoid some exceptions and clean up log spam.

Co-authored-by: Addison Higham <ahigham@instructure.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/security release/2.5.1 type/bug The PR fixed a bug or issue reported a bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants