-
Notifications
You must be signed in to change notification settings - Fork 120
Add request filter for early user and query parsing #748
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
Conversation
gateway-ha/src/main/java/io/trino/gateway/ha/config/HaGatewayConfiguration.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Show resolved
Hide resolved
5c57364 to
28caef2
Compare
|
Addressed the review comments. |
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryMetadataParser.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryMetadataParser.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryUserInfoParser.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryUserInfoParser.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryMetadataParser.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/handler/TestQueryIdCachingProxyHandler.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/security/TestQueryMetadataParser.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/security/TestQueryMetadataParser.java
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/security/TestQueryMetadataParser.java
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/security/TestQueryUserInfoParser.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/security/TestQueryUserInfoParser.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/security/TestQueryUserInfoParser.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/security/TestQueryUserInfoParser.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/test/java/io/trino/gateway/ha/router/TestExternalRoutingGroupSelector.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/util/Priorities.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/util/Priorities.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryUserInfoParser.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryMetadataParser.java
Outdated
Show resolved
Hide resolved
239f66a to
68e1860
Compare
|
How about using a single filter to parse all the data instead of having multiple filters? |
|
I would like to keep it separate as they are different and will be parsed at different priorities (user info might need to be parsed at pre-authentication and query might be parsed at pre-authorization), The query information may not be present for all the requests. |
b97df7f to
b202da0
Compare
|
Added a new |
|
@ebyhr - I have addressed the review comments. |
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryUserInfoParser.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryUserInfoParser.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/PathFilter.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/PathFilter.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryMetadataParser.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryMetadataParser.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/router/TrinoQueryProperties.java
Outdated
Show resolved
Hide resolved
910492f to
1d71ebd
Compare
1d71ebd to
48a3b6f
Compare
|
@vishalya are you still working on this? Would love to see it land -- this is a great cleanup |
|
I’ll spend some time on the code comments this week |
48a3b6f to
e20aff9
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Can you resolve comments if they are addressed :)
gateway-ha/src/main/java/io/trino/gateway/ha/router/PathFilter.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryUserInfoParser.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryUserInfoParser.java
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryMetadataParser.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryMetadataParser.java
Outdated
Show resolved
Hide resolved
gateway-ha/src/main/java/io/trino/gateway/ha/security/QueryMetadataParser.java
Outdated
Show resolved
Hide resolved
9ea3587 to
bf4cdbf
Compare
bf4cdbf to
a75b9fe
Compare
|
Let's get this merged. This refactoring would affect others quite a bit. |
| public PathFilter( | ||
| List<String> statementPaths, | ||
| List<String> extraWhitelistPaths) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please inject HaGatewayConfiguration instead.
| List<String> statementPaths, | ||
| List<String> extraWhitelistPaths) | ||
| { | ||
| this.statementPaths = Set.copyOf(requireNonNull(statementPaths, "Required configuration 'statementPaths' can't be null")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use ImmutableSet.copyOf and remove requireNonNull.
| this("", "", "", ImmutableList.of(), Optional.empty(), Optional.empty(), | ||
| ImmutableSet.of(), ImmutableSet.of(), ImmutableSet.of(), false, Optional.empty()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The convention is single line or separate lines.
this(
"",
"",
"",
ImmutableList.of(),
Optional.empty(),
Optional.empty(),
ImmutableSet.of(),
ImmutableSet.of(),
ImmutableSet.of(),
false,
Optional.empty());| private Optional<String> extractUserFromCookies(ContainerRequestContext requestContext, String userField) | ||
| { | ||
| if (request.getCookies() == null) { | ||
| Map<String, jakarta.ws.rs.core.Cookie> cookies = requestContext.getCookies(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Import jakarta.ws.rs.core.Cookie.
| private static final int MAX_QUERY_TEXT_LOG_LENGTH = 100; | ||
| private final boolean isAnalyzeRequest; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add an empty line between constants and fields.
| try { | ||
| when(uriInfo.getRequestUri()).thenReturn(new URI("http://localhost" + HttpUtils.OAUTH_PATH)); | ||
| } | ||
| catch (URISyntaxException e) { | ||
| throw new RuntimeException(e); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant try-catch.
| try { | ||
| when(uriInfo.getRequestUri()).thenReturn(new URI("http://localhost" + HttpUtils.V1_STATEMENT_PATH)); | ||
| } | ||
| catch (URISyntaxException e) { | ||
| throw new RuntimeException(e); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant try-catch.
| try { | ||
| when(uriInfo.getRequestUri()).thenReturn(new URI("http://localhost" + HttpUtils.V1_STATEMENT_PATH)); | ||
| } | ||
| catch (URISyntaxException e) { | ||
| throw new RuntimeException(e); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant try-catch.
| try { | ||
| when(uriInfo.getRequestUri()).thenReturn(new URI("http://localhost" + HttpUtils.V1_STATEMENT_PATH)); | ||
| } | ||
| catch (URISyntaxException e) { | ||
| throw new RuntimeException(e); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove redundant try-catch.
|
|
||
| final class TestQueryUserInfoParser | ||
| { | ||
| private QueryUserInfoParser filter; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make this field constant.
Description
The parsing of the user and query was happening at different places and at a later stages, this PR structures it to happen at a early stage and a single point in time.
Additional context and related issues
Release notes
(X) This is not user-visible or is docs only, and no release notes are required.
( ) Release notes are required, with the following suggested text: