-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix: Internal Server Error for /healthcheck endpoint in RBAC-enabled #6482
Conversation
6403832
to
1202d41
Compare
1202d41
to
807260d
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.
Hey @spena , I don't think this is the right way to address this bug. This PR fixes the issue for the default unauthenticated paths, but it doesn't solve the problem more generally. For example, if a user chooses to make the /ksql
endpoint unauthenticated (not sure why anyone would do that but bear with me 😆), then they would again hit the bug in the Github issue. I'd need to dig into the code more in order to figure out the proper way to fix this. It might involve changes around ApiSecurityContext. Ping me tomorrow if you want to brainstorm together offline?
@@ -539,7 +612,7 @@ private void shouldNotAllowAccessIfPermissionCheckThrowsException( | |||
void run() throws Exception; | |||
} | |||
|
|||
private static class StringPrincipal implements Principal { | |||
public static class StringPrincipal implements Principal { |
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.
Why can't this still be private?
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.
Left from another approach I was taking. Fixed.
@@ -32,7 +32,7 @@ | |||
*/ | |||
public class KsqlAuthorizationProviderHandler implements Handler<RoutingContext> { | |||
|
|||
public static final Set<String> PATHS_WITHOUT_AUTHORIZATION = ImmutableSet | |||
public static final Set<String> KSQL_AUTHENTICATION_SKIP_PATHS = ImmutableSet |
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.
Can we move this into AuthenticationPluginHandler
if we're going to rename it? It looks out of place here.
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.
done
protected HttpResponse<Buffer> sendGetRequest(final String uri) throws Exception { | ||
return sendGetRequestWithCreds(client, uri, USER_WITH_ACCESS, USER_WITH_ACCESS_PWD); | ||
} | ||
|
||
@Override | ||
protected HttpResponse<Buffer> sendRequest(final WebClient client, final String uri, |
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.
nit: can we rename this to sendPostRequest()
in light of the new method above?
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.
done
request.send(requestFuture); | ||
return requestFuture.get(); | ||
} | ||
|
||
private HttpResponse<Buffer> sendRequestWithCreds( |
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.
nit: can we rename this to sendPostRequestWithCreds()
in light of the new method above?
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.
Done
@vcrfxia You're right. I was expecting that whenever an endpoint required a service context, then the authentication would require a user to create one. It's just lucky that we don't have an endpoint that requires a service context with no authentication. I fixed the issue, and now I create a default service context when there is a missing user. I left a comment in the code about why there's no problem about it. I added tests to the DefaultKsqlServiceContextProvider, I copied the tests we had for this class (https://github.com/confluentinc/ksql/blob/5.5.x/ksqldb-rest-app/src/test/java/io/confluent/ksql/rest/server/context/KsqlSecurityContextBinderFactoryTest.java), and added just one when the user missing. I also noticed that the I verified the endpoints work manually again. |
ffca842
to
553fc18
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.
Thanks @spena -- LGTM with a suggested update to clarify the missing user case.
...db-rest-app/src/main/java/io/confluent/ksql/api/impl/DefaultKsqlSecurityContextProvider.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Victoria Xia <victoria.f.xia281@gmail.com>
e93c035
to
50cbb75
Compare
Description
Fixes #6479
Context:
There are endpoints in
KsqlServerEndpoints
that do not require a security context initialized. Some of these endpoints do not require authentication, so a security context should not be initialized because there is noPrincipal
authenticated.The current Vert.x code in
KsqlServerEndpoints
attempted to initialize the security context on endpoints where the user was not authenticated. This caused an error when calling these endpoints even with valid credentials. The fix was just to prevent initializing the security contexts, which is unnecessary.Testing done
Added unit tests.
Verified manually with Confluent RBAC library.
User:ksql
has valid credentials and has authorization to the server.User:user1
has valid credentials but not authorization to the server.Reviewer checklist