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

adapter: Prevent login to mz_system externally #14093

Merged
merged 14 commits into from
Aug 15, 2022
Prev Previous commit
Next Next commit
Change method name
  • Loading branch information
jkosh44 committed Aug 11, 2022
commit 8c309708dec0a7122e76376524134fc10c5d816b
6 changes: 3 additions & 3 deletions src/adapter/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ impl ConnClient {
session: Session,
create_user_if_not_exists: bool,
) -> Result<(SessionClient, StartupResponse), AdapterError> {
self.validate_user(session.user())?;
self.is_user_disallowed_by_client_type(session.user())?;

// Cancellation works by creating a watch channel (which remembers only
// the last value sent to it) and sharing it between the coordinator and
Expand Down Expand Up @@ -200,8 +200,8 @@ impl ConnClient {
}
}

/// Validate that the user is allowed to login.
fn validate_user(&self, user: &str) -> Result<(), AdapterError> {
/// Returns an error if the user is not permitted to log in to the ClientType.
fn is_user_disallowed_by_client_type(&self, user: &str) -> Result<(), AdapterError> {
match (&self.inner.client_type, user) {
(ClientType::Internal, SYSTEM_USER) => Ok(()),
(ClientType::Internal, _) => Err(AdapterError::UnauthorizedLogin(user.to_string())),
Expand Down