Skip to content

Attach user identity to router request logs#15126

Merged
a2l007 merged 4 commits into
apache:masterfrom
a2l007:routeridentity
Oct 19, 2023
Merged

Attach user identity to router request logs#15126
a2l007 merged 4 commits into
apache:masterfrom
a2l007:routeridentity

Conversation

@a2l007

@a2l007 a2l007 commented Oct 10, 2023

Copy link
Copy Markdown
Contributor

Description

This PR attaches user identity to the query request logs on the router. Having the user identity present in the router request logs is useful when druid security is enabled only on the routers.
Sample query request logs on the router would now look like this:
{"query/time":94,"success":false,"identity":"a2l007"} {"query":"select * from \"testdata\"","context":{"sqlQueryId":"sqlQuerytest1","sqlOuterLimit":1001,"queryId":"sqlQuerytest1"}}


Key changed/added classes in this PR
  • AsyncQueryForwardingServlet

This PR has:

  • been self-reviewed.
  • been tested in a test Druid cluster.

}
emitQueryTime(requestTimeNs, success, sqlQueryId, queryId);

AuthenticationResult authenticationResult = AuthorizationUtils.authenticationResultFromRequest(req);

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 would throw an exception if DRUID_AUTHENTICATION_RESULT attribute is not set. can we not get the request directly and avoid possibility of that exception being thrown?

@a2l007 a2l007 Oct 12, 2023

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.

Since we are attaching an authenticator even if the authenticators are null, I'd expect the request would have an auth result every time. The QueryLifecycle also uses the same method and so if there were a failure, it would fail before the request comes back to the router. What do you think?

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.

Yeah. I did check that, too. Just being more risk averse, I guess. I am going to approve. Feel free to merge once CI is green. Those failures are likely code coverage issues.

@a2l007

a2l007 commented Oct 19, 2023

Copy link
Copy Markdown
Contributor Author

Thanks for the review @abhishekagarwal87

@a2l007
a2l007 merged commit 7802078 into apache:master Oct 19, 2023
CaseyPan pushed a commit to CaseyPan/druid that referenced this pull request Nov 17, 2023
* Attach user identity to router request logs

* Add test

* More tests
ratishr pushed a commit to confluentinc/druid that referenced this pull request Jan 4, 2024
* Attach user identity to router request logs

* Add test

* More tests

(cherry picked from commit 7802078)
ratishr added a commit to confluentinc/druid that referenced this pull request Jan 4, 2024
* Attach user identity to router request logs

* Add test

* More tests

(cherry picked from commit 7802078)

Co-authored-by: Atul Mohan <[email protected]>
@LakshSingla LakshSingla added this to the 29.0.0 milestone Jan 29, 2024
riovic918data pushed a commit to riovic918data/druid that referenced this pull request Jun 12, 2026
* Attach user identity to router request logs

* Add test

* More tests
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants