Skip to content

Conversation

@pan3793
Copy link
Member

@pan3793 pan3793 commented Aug 19, 2022

Why are the changes needed?

This is the followup of #3235, the main change is introdude JdbcUtils to simplify code, and allow empty password for Jdbc auth.

Jdbc connection pool has been removed because JdbcAuthenticationProviderImpl will be created on each connection, we can improve to use singleton in the future

How was this patch tested?

  • Add some test cases that check the changes thoroughly including negative and positive cases if possible

  • Add screenshots for manual tests if appropriate

  • Run test locally before make a pull request

@pan3793 pan3793 added this to the v1.6.0 milestone Aug 19, 2022
@pan3793 pan3793 marked this pull request as ready for review August 19, 2022 09:12
@pan3793
Copy link
Member Author

pan3793 commented Aug 19, 2022

cc @bowenliang123

@bowenliang123
Copy link
Contributor

bowenliang123 commented Aug 19, 2022

Well learned from this pr. It is much resuable and elegant in scala style after refactoring.

@turboFei
Copy link
Member

JdbcAuthenticationProviderImplSuite:
- authenticate tests *** FAILED ***
  "requirement failed: JDBC driver class is not configured." did not contain "JDBC url is not configured" (JdbcAuthenticationProviderImplSuite.scala:106)

@pan3793 pan3793 self-assigned this Aug 19, 2022
@codecov-commenter
Copy link

codecov-commenter commented Aug 20, 2022

Codecov Report

Merging #3278 (2863cae) into master (97b14f8) will decrease coverage by 0.00%.
The diff coverage is 76.62%.

@@             Coverage Diff              @@
##             master    #3278      +/-   ##
============================================
- Coverage     51.37%   51.37%   -0.01%     
  Complexity       13       13              
============================================
  Files           468      469       +1     
  Lines         26222    26229       +7     
  Branches       3633     3630       -3     
============================================
+ Hits          13472    13474       +2     
- Misses        11467    11469       +2     
- Partials       1283     1286       +3     
Impacted Files Coverage Δ
...uthentication/JdbcAuthenticationProviderImpl.scala 73.21% <68.88%> (-6.54%) ⬇️
.../main/scala/org/apache/kyuubi/util/JdbcUtils.scala 87.50% <87.50%> (ø)
...apache/kyuubi/engine/JpsApplicationOperation.scala 77.41% <0.00%> (-3.23%) ⬇️
...pache/kyuubi/engine/YarnApplicationOperation.scala 64.81% <0.00%> (-1.86%) ⬇️
...ain/scala/org/apache/kyuubi/engine/EngineRef.scala 74.07% <0.00%> (-0.93%) ⬇️
...uthentication/LdapAuthenticationProviderImpl.scala 95.23% <0.00%> (-0.15%) ⬇️
...g/apache/kyuubi/operation/BatchJobSubmission.scala 74.40% <0.00%> (ø)
...he/kyuubi/ha/client/etcd/EtcdDiscoveryClient.scala 68.12% <0.00%> (+0.62%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@pan3793 pan3793 requested a review from turboFei August 20, 2022 06:12
@pan3793
Copy link
Member Author

pan3793 commented Aug 20, 2022

@turboFei UT has been enhanced and CI passed now, please take a look again.

@bowenliang123
Copy link
Contributor

@pan3793 May I suggest to change change a config name from kyuubi.authentication.jdbc.username to kyuubi.authentication.jdbc.user ?

kyuubi.authentication.jdbc.username was introduced in my initial code for issue 3222, but I think user is than suitable name than username, sinceDriverManager.getConnection takesuser param in Java and we also have kyuubi.metadata.store.jdbc.user in KuyuubiConf.

Or I could fill anther PR for this very soon to fix this, better for release with 1.6.0.

}
if (!query.contains("${username}")) {
warn("Query SQL does not contains '${username}' placeholder")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
}
}
if (!query.contains("${password}")) {
warn("Query SQL does not contains '${password}' placeholder")
}

How about adding check for ${password} placeholder here, as auth method checked password not blank in first place? @pan3793

Copy link
Member Author

@pan3793 pan3793 Aug 20, 2022

Choose a reason for hiding this comment

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

added warning message

s" or contains blank space")
}

if (StringUtils.isBlank(password)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we bring back password not blank checking? If auth method allow passing with missing password, the whole authentication relies on the confidentiality of username alone. @pan3793

Copy link
Member Author

Choose a reason for hiding this comment

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

I think we should allow empty password, and the auth query will fail the athentication is password is required.

Copy link
Contributor

Choose a reason for hiding this comment

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

agree

throw new AuthenticationException(s"Password does not match or no such user. user:" +
s" $user , password length: ${password.length}")
debug(s"prepared auth query: $preparedQuery")
JdbcUtils.executeQuery(preparedQuery) { stmt =>
Copy link
Contributor

Choose a reason for hiding this comment

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

shall we a add a query time out for JdbcUtils.executeQuery to prevent blocking out of connection timeout ?

Copy link
Member Author

Choose a reason for hiding this comment

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

we can extend KyuubiConf to allow configuring arbitrary properties, but it's out of scope in this PR, better do it in new PR.

pan3793 and others added 3 commits August 20, 2022 16:51
…ication/JdbcAuthenticationProviderImplSuite.scala

Co-authored-by: Bowen Liang <[email protected]>
@pan3793
Copy link
Member Author

pan3793 commented Aug 20, 2022

Or I could fill anther PR for this very soon to fix this, better for release with 1.6.0.

You can send a followup PR if you have time :)

Copy link
Contributor

@bowenliang123 bowenliang123 left a comment

Choose a reason for hiding this comment

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

LGTM.

For the change in kuubi.authentication.jdbc.user config name, i will fill a PR soon after this PR merged.

@pan3793
Copy link
Member Author

pan3793 commented Aug 20, 2022

Thanks, merging to master/1.6

@pan3793 pan3793 closed this in d0f75e8 Aug 20, 2022
pan3793 added a commit that referenced this pull request Aug 20, 2022
### _Why are the changes needed?_

This is the followup of #3235, the main change is introdude `JdbcUtils` to simplify code, and allow empty password for Jdbc auth.

Jdbc connection pool has been removed because `JdbcAuthenticationProviderImpl` will be created on each connection, we can improve to use singleton in the future

### _How was this patch tested?_
- [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible

- [ ] Add screenshots for manual tests if appropriate

- [x] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request

Closes #3278 from pan3793/jdbc-followup.

Closes #3222

2863cae [Cheng Pan] Update kyuubi-common/src/test/scala/org/apache/kyuubi/service/authentication/JdbcAuthenticationProviderImplSuite.scala
51a9c45 [Cheng Pan] Update kyuubi-common/src/test/scala/org/apache/kyuubi/service/authentication/JdbcAuthenticationProviderImplSuite.scala
eee3c55 [Cheng Pan] Update kyuubi-common/src/test/scala/org/apache/kyuubi/util/JdbcUtilsSuite.scala
d02bb99 [Cheng Pan] nit
e001b5b [Cheng Pan] nit
8cf5cd6 [Cheng Pan] nit
032f2df [Cheng Pan] nit
8a42f18 [Cheng Pan] nit
c7893fd [Cheng Pan] JdbcUtilsSuite
f97f2d9 [Cheng Pan] remove pool
a8812d0 [Cheng Pan] move render result set to test
83d7d4c [Cheng Pan] fix ut
db787a4 [Cheng Pan] nit
864f9dd [Cheng Pan] nit
b60decf [Cheng Pan] nit
8c66e0b [Cheng Pan] nit
2063c43 [Cheng Pan] [KYUUBI #3222][FOLLOWUP] Introdude JdbcUtils to simplify code

Authored-by: Cheng Pan <[email protected]>
Signed-off-by: Cheng Pan <[email protected]>
(cherry picked from commit d0f75e8)
Signed-off-by: Cheng Pan <[email protected]>
@pan3793 pan3793 deleted the jdbc-followup branch August 20, 2022 13:16
} { resultSet =>
if (resultSet == null || !resultSet.next()) {
throw new AuthenticationException("Password does not match or no such user. " +
s"user: $user, password: $redactedPasswd")
Copy link
Contributor

Choose a reason for hiding this comment

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

@pan3793 It seems throwing woring redacted password with authdb password. It should throws with connection password. Let me fix it in next PR?

Copy link
Member Author

@pan3793 pan3793 Aug 20, 2022

Choose a reason for hiding this comment

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

Oh, my fault, thanks for catching this issue. Sure, let's fix it in followup

Copy link
Contributor

Choose a reason for hiding this comment

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

Good. And we have the fix and ut in #3288 now.

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.

4 participants