zhujunxxxxx commented on a change in pull request #10310:
URL: https://github.com/apache/shardingsphere/pull/10310#discussion_r630971183
##########
File path:
shardingsphere-proxy/shardingsphere-proxy-frontend/shardingsphere-proxy-frontend-mysql/src/main/java/org/apache/shardingsphere/proxy/frontend/mysql/authentication/MySQLAuthenticationHandler.java
##########
@@ -53,14 +57,24 @@
* @return login success or failure
*/
public Optional<MySQLServerErrorCode> login(final String username, final
String hostname, final byte[] authenticationResponse, final String
databaseName) {
- Optional<ShardingSphereUser> user =
ProxyContext.getInstance().getMetaDataContexts().getUsers().findUser(new
Grantee(username, hostname));
+ Optional<ShardingSphereUser> user =
getUsersFromGlobalRuleMetaData().findUser(new Grantee(username, hostname));
if (!user.isPresent() || !isPasswordRight(user.get().getPassword(),
authenticationResponse)) {
return Optional.of(MySQLServerErrorCode.ER_ACCESS_DENIED_ERROR);
}
return null == databaseName || SQLCheckEngine.check(databaseName,
getRules(databaseName), user.get().getGrantee())
? Optional.empty() :
Optional.of(MySQLServerErrorCode.ER_DBACCESS_DENIED_ERROR);
}
-
+
+ private ShardingSphereUsers getUsersFromGlobalRuleMetaData() {
+ for (RuleConfiguration ruleConfig :
ProxyContext.getInstance().getMetaDataContexts().getGlobalRuleMetaData().getConfigurations())
{
+ if (ruleConfig instanceof AuthorityRuleConfiguration) {
+ AuthorityRuleConfiguration authorityRuleConfiguration =
(AuthorityRuleConfiguration) ruleConfig;
+ return new
ShardingSphereUsers(authorityRuleConfiguration.getUsers());
+ }
+ }
+ return new ShardingSphereUsers(Collections.emptyList());
+ }
Review comment:
Good idea.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]