diff --git a/orm/src/main/java/com/zfoo/orm/config/HostConfig.java b/orm/src/main/java/com/zfoo/orm/config/HostConfig.java index f24aa42eb..eca85be01 100644 --- a/orm/src/main/java/com/zfoo/orm/config/HostConfig.java +++ b/orm/src/main/java/com/zfoo/orm/config/HostConfig.java @@ -23,13 +23,15 @@ public class HostConfig { private String user; private String password; private Map address; + private String authSource; - public static HostConfig valueOf(String database, String user, String password, Map addressMap) { + public static HostConfig valueOf(String database, String user, String password, Map addressMap, String authSource) { HostConfig config = new HostConfig(); config.database = database; config.user = user; config.password = password; config.address = addressMap; + config.authSource = authSource; return config; } @@ -64,4 +66,12 @@ public Map getAddress() { public void setAddress(Map address) { this.address = address; } + + public String getAuthSource() { + return authSource; + } + + public void setAuthSource(String authSource) { + this.authSource = authSource; + } } diff --git a/orm/src/main/java/com/zfoo/orm/manager/OrmManager.java b/orm/src/main/java/com/zfoo/orm/manager/OrmManager.java index 6ce95ccc4..38f0088ee 100644 --- a/orm/src/main/java/com/zfoo/orm/manager/OrmManager.java +++ b/orm/src/main/java/com/zfoo/orm/manager/OrmManager.java @@ -118,7 +118,10 @@ public void initBefore() { // 设置数据库账号密码 if (StringUtils.isNotBlank(hostConfig.getUser()) && StringUtils.isNotBlank(hostConfig.getPassword())) { - mongoBuilder.credential(MongoCredential.createCredential(hostConfig.getUser(), "admin", hostConfig.getPassword().toCharArray())); + var authSource = "admin"; + if (hostConfig.getAuthSource() != null) + authSource = hostConfig.getAuthSource(); + mongoBuilder.credential(MongoCredential.createCredential(hostConfig.getUser(), authSource, hostConfig.getPassword().toCharArray())); } // 设置连接池的大小 diff --git a/orm/src/main/resources/orm-1.0.xsd b/orm/src/main/resources/orm-1.0.xsd index 00ad0f512..6b5fa7b93 100644 --- a/orm/src/main/resources/orm-1.0.xsd +++ b/orm/src/main/resources/orm-1.0.xsd @@ -32,6 +32,7 @@ +