disable mailcow keycloak logs
All checks were successful
deploy / deploy (push) Successful in 29s

This commit is contained in:
Denys Konovalov 2024-06-15 14:28:46 +02:00
parent 8050a9007a
commit 804d1441f9
2 changed files with 18 additions and 19 deletions

@ -49,19 +49,19 @@ public class mailcowUserStorageProvider implements UserStorageProvider,
@Override @Override
public void close() { public void close() {
logger.info("[mailcow] close()"); logger.debug("[mailcow] close()");
} }
@Override @Override
public UserModel getUserById(RealmModel realm, String id) { public UserModel getUserById(RealmModel realm, String id) {
logger.info("[mailcow] getUserById({})", id); logger.debug("[mailcow] getUserById({})", id);
StorageId sid = new StorageId(id); StorageId sid = new StorageId(id);
return getUserByUsername(realm, sid.getExternalId()); return getUserByUsername(realm, sid.getExternalId());
} }
@Override @Override
public UserModel getUserByUsername(RealmModel realm, String username) { public UserModel getUserByUsername(RealmModel realm, String username) {
logger.info("[mailcow] getUserByUsername({})", username); logger.debug("[mailcow] getUserByUsername({})", username);
try (Connection c = DbUtil.getConnection(this.model)) { try (Connection c = DbUtil.getConnection(this.model)) {
PreparedStatement st = c.prepareStatement( PreparedStatement st = c.prepareStatement(
"select username, name, `mailbox`.`domain`, local_part FROM `mailbox` INNER JOIN domain on mailbox.domain = domain.domain WHERE `mailbox`.`active` = '1' AND `domain`.`active`='1' AND username = ?"); "select username, name, `mailbox`.`domain`, local_part FROM `mailbox` INNER JOIN domain on mailbox.domain = domain.domain WHERE `mailbox`.`active` = '1' AND `domain`.`active`='1' AND username = ?");
@ -80,7 +80,7 @@ public class mailcowUserStorageProvider implements UserStorageProvider,
@Override @Override
public UserModel getUserByEmail(RealmModel realm, String email) { public UserModel getUserByEmail(RealmModel realm, String email) {
logger.info("[mailcow] getUserByEmail({})", email); logger.debug("[mailcow] getUserByEmail({})", email);
try (Connection c = DbUtil.getConnection(this.model)) { try (Connection c = DbUtil.getConnection(this.model)) {
PreparedStatement st = c.prepareStatement( PreparedStatement st = c.prepareStatement(
"select username, name, `mailbox`.`domain`, local_part FROM `mailbox` INNER JOIN domain on mailbox.domain = domain.domain WHERE `mailbox`.`active` = '1' AND `domain`.`active`='1' AND username = ?"); "select username, name, `mailbox`.`domain`, local_part FROM `mailbox` INNER JOIN domain on mailbox.domain = domain.domain WHERE `mailbox`.`active` = '1' AND `domain`.`active`='1' AND username = ?");
@ -99,13 +99,13 @@ public class mailcowUserStorageProvider implements UserStorageProvider,
@Override @Override
public boolean supportsCredentialType(String credentialType) { public boolean supportsCredentialType(String credentialType) {
logger.info("[mailcow] supportsCredentialType({})", credentialType); logger.debug("[mailcow] supportsCredentialType({})", credentialType);
return PasswordCredentialModel.TYPE.endsWith(credentialType); return PasswordCredentialModel.TYPE.endsWith(credentialType);
} }
@Override @Override
public boolean isConfiguredFor(RealmModel realm, UserModel user, String credentialType) { public boolean isConfiguredFor(RealmModel realm, UserModel user, String credentialType) {
logger.info("[mailcow] isConfiguredFor(realm={},user={},credentialType={})", realm.getName(), logger.debug("[mailcow] isConfiguredFor(realm={},user={},credentialType={})", realm.getName(),
user.getUsername(), credentialType); user.getUsername(), credentialType);
// In our case, password is the only type of credential, so we allways return // In our case, password is the only type of credential, so we allways return
// 'true' if // 'true' if
@ -114,7 +114,7 @@ public class mailcowUserStorageProvider implements UserStorageProvider,
} }
private boolean verifyHash(String hash, String password) { private boolean verifyHash(String hash, String password) {
logger.info("[mailcow] verifyHash"); logger.debug("[mailcow] verifyHash");
Pattern pattern = Pattern.compile("\\{(.+)\\}(.+)"); Pattern pattern = Pattern.compile("\\{(.+)\\}(.+)");
Matcher matcher = pattern.matcher(hash); Matcher matcher = pattern.matcher(hash);
while (matcher.find()) { while (matcher.find()) {
@ -128,7 +128,7 @@ public class mailcowUserStorageProvider implements UserStorageProvider,
@Override @Override
public boolean isValid(RealmModel realm, UserModel user, CredentialInput credentialInput) { public boolean isValid(RealmModel realm, UserModel user, CredentialInput credentialInput) {
logger.info("[mailcow] isValid(realm={},user={},credentialInput.type={})", realm.getName(), user.getUsername(), logger.debug("[mailcow] isValid(realm={},user={},credentialInput.type={})", realm.getName(), user.getUsername(),
credentialInput.getType()); credentialInput.getType());
if (!this.supportsCredentialType(credentialInput.getType())) { if (!this.supportsCredentialType(credentialInput.getType())) {
return false; return false;
@ -157,7 +157,7 @@ public class mailcowUserStorageProvider implements UserStorageProvider,
@Override @Override
public int getUsersCount(RealmModel realm) { public int getUsersCount(RealmModel realm) {
logger.info("[mailcow] getUsersCount: realm={}", realm.getName()); logger.debug("[mailcow] getUsersCount: realm={}", realm.getName());
try (Connection c = DbUtil.getConnection(this.model)) { try (Connection c = DbUtil.getConnection(this.model)) {
Statement st = c.createStatement(); Statement st = c.createStatement();
st.execute( st.execute(
@ -173,7 +173,7 @@ public class mailcowUserStorageProvider implements UserStorageProvider,
@Override @Override
public Stream<UserModel> getGroupMembersStream(RealmModel realm, GroupModel group, Integer firstResult, public Stream<UserModel> getGroupMembersStream(RealmModel realm, GroupModel group, Integer firstResult,
Integer maxResults) { Integer maxResults) {
logger.info("[mailcow] getUsers: realm={}", realm.getName()); logger.debug("[mailcow] getUsers: realm={}", realm.getName());
try (Connection c = DbUtil.getConnection(this.model)) { try (Connection c = DbUtil.getConnection(this.model)) {
PreparedStatement st = c.prepareStatement( PreparedStatement st = c.prepareStatement(
@ -182,7 +182,6 @@ public class mailcowUserStorageProvider implements UserStorageProvider,
st.setInt(2, firstResult); st.setInt(2, firstResult);
st.execute(); st.execute();
ResultSet rs = st.getResultSet(); ResultSet rs = st.getResultSet();
logger.info(rs.toString());
List<UserModel> users = new ArrayList<>(); List<UserModel> users = new ArrayList<>();
while (rs.next()) { while (rs.next()) {
users.add(mapUser(realm, rs)); users.add(mapUser(realm, rs));
@ -198,7 +197,7 @@ public class mailcowUserStorageProvider implements UserStorageProvider,
Integer maxResults) { Integer maxResults) {
String search = params.get(UserModel.SEARCH); String search = params.get(UserModel.SEARCH);
logger.info("[mailcow] searchForUser: realm={}, search={}", realm.getName(), search); logger.debug("[mailcow] searchForUser: realm={}, search={}", realm.getName(), search);
try (Connection c = DbUtil.getConnection(this.model)) { try (Connection c = DbUtil.getConnection(this.model)) {
PreparedStatement st; PreparedStatement st;

@ -20,7 +20,7 @@ public class mailcowUserStorageProviderFactory implements UserStorageProviderFac
protected final List<ProviderConfigProperty> configMetadata; protected final List<ProviderConfigProperty> configMetadata;
public mailcowUserStorageProviderFactory() { public mailcowUserStorageProviderFactory() {
logger.info("[mailcow] mailcowUserStorageProviderFactory created"); logger.debug("[mailcow] mailcowUserStorageProviderFactory created");
// Create config metadata // Create config metadata
configMetadata = ProviderConfigurationBuilder.create() configMetadata = ProviderConfigurationBuilder.create()
@ -64,13 +64,13 @@ public class mailcowUserStorageProviderFactory implements UserStorageProviderFac
@Override @Override
public mailcowUserStorageProvider create(KeycloakSession ksession, ComponentModel model) { public mailcowUserStorageProvider create(KeycloakSession ksession, ComponentModel model) {
logger.info("[mailcow] creating new mailcowUserStorageProvider"); logger.debug("[mailcow] creating new mailcowUserStorageProvider");
return new mailcowUserStorageProvider(ksession, model); return new mailcowUserStorageProvider(ksession, model);
} }
@Override @Override
public String getId() { public String getId() {
logger.info("[mailcow] getId()"); logger.debug("[mailcow] getId()");
return "mailcow-user-provider"; return "mailcow-user-provider";
} }
@ -85,9 +85,9 @@ public class mailcowUserStorageProviderFactory implements UserStorageProviderFac
throws ComponentValidationException { throws ComponentValidationException {
try (Connection c = DbUtil.getConnection(config)) { try (Connection c = DbUtil.getConnection(config)) {
logger.info("[mailcow] Testing connection..."); logger.debug("[mailcow] Testing connection...");
c.createStatement().execute(config.get(CONFIG_KEY_VALIDATION_QUERY)); c.createStatement().execute(config.get(CONFIG_KEY_VALIDATION_QUERY));
logger.info("[mailcow] Connection OK !"); logger.debug("[mailcow] Connection OK !");
} catch (Exception ex) { } catch (Exception ex) {
logger.warn("[mailcow] Unable to validate connection: ex={}", ex.getMessage()); logger.warn("[mailcow] Unable to validate connection: ex={}", ex.getMessage());
throw new ComponentValidationException("Unable to validate database connection", ex); throw new ComponentValidationException("Unable to validate database connection", ex);
@ -96,11 +96,11 @@ public class mailcowUserStorageProviderFactory implements UserStorageProviderFac
@Override @Override
public void onUpdate(KeycloakSession session, RealmModel realm, ComponentModel oldModel, ComponentModel newModel) { public void onUpdate(KeycloakSession session, RealmModel realm, ComponentModel oldModel, ComponentModel newModel) {
logger.info("[mailcow] onUpdate()"); logger.debug("[mailcow] onUpdate()");
} }
@Override @Override
public void onCreate(KeycloakSession session, RealmModel realm, ComponentModel model) { public void onCreate(KeycloakSession session, RealmModel realm, ComponentModel model) {
logger.info("[mailcow] onCreate()"); logger.debug("[mailcow] onCreate()");
} }
} }