Skip to content

Commit 31ccf56

Browse files
Merge pull request #1450 from hivemq/bug/EDG-191/ldap-auth-improvements-configuration-via-helm-charts-empty-queries
EDG-191 LDAP Auth Improvements configuration via Helm Charts - allow empty user role queries
2 parents 27c377c + 47cfd16 commit 31ccf56

File tree

4 files changed

+5
-11
lines changed

4 files changed

+5
-11
lines changed

docker/config-k8s.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -124,24 +124,18 @@
124124

125125
${IF:HIVEMQ_LDAP_USER_ROLES_ENABLED}
126126
<user-roles>
127-
${IF:HIVEMQ_LDAP_USER_ROLE_ADMIN_QUERY}
128127
<user-role>
129128
<role>ADMIN</role>
130129
<query>${ENV:HIVEMQ_LDAP_USER_ROLE_ADMIN_QUERY}</query>
131130
</user-role>
132-
${IF:HIVEMQ_LDAP_USER_ROLE_ADMIN_QUERY}
133-
${IF:HIVEMQ_LDAP_USER_ROLE_SUPER_QUERY}
134131
<user-role>
135132
<role>SUPER</role>
136133
<query>${ENV:HIVEMQ_LDAP_USER_ROLE_SUPER_QUERY}</query>
137134
</user-role>
138-
${IF:HIVEMQ_LDAP_USER_ROLE_SUPER_QUERY}
139-
${IF:HIVEMQ_LDAP_USER_ROLE_USER_QUERY}
140135
<user-role>
141136
<role>USER</role>
142137
<query>${ENV:HIVEMQ_LDAP_USER_ROLE_USER_QUERY}</query>
143138
</user-role>
144-
${IF:HIVEMQ_LDAP_USER_ROLE_USER_QUERY}
145139
</user-roles>
146140
${IF:HIVEMQ_LDAP_USER_ROLES_ENABLED}
147141

hivemq-edge/src/main/java/com/hivemq/api/auth/provider/impl/ldap/LdapClient.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,9 @@ public boolean authenticateUser(final @NotNull String username, final byte @NotN
295295
for (final var userRole : userRoles) {
296296
final String role = userRole.getRole();
297297
final String queryTemplate = userRole.getQuery();
298+
if (queryTemplate.isBlank()) {
299+
continue;
300+
}
298301
try {
299302
// Substitute {userDn} placeholder in query
300303
final String query = queryTemplate.replace("{userDn}", userDn);

hivemq-edge/src/main/java/com/hivemq/util/render/IfUtil.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,7 @@ public class IfUtil {
4949
"HIVEMQ_USERS_ENABLED",
5050
"HIVEMQ_LDAP_OBJECT_CLASS_ENABLED",
5151
"HIVEMQ_PRE_LOGIN_NOTICE_ENABLED",
52-
"HIVEMQ_LDAP_USER_ROLES_ENABLED",
53-
"HIVEMQ_LDAP_USER_ROLE_ADMIN_QUERY",
54-
"HIVEMQ_LDAP_USER_ROLE_SUPER_QUERY",
55-
"HIVEMQ_LDAP_USER_ROLE_USER_QUERY");
52+
"HIVEMQ_LDAP_USER_ROLES_ENABLED");
5653

5754
/**
5855
* Get a Java system property or system environment variable with the specified name.

hivemq-edge/src/main/resources/config.xsd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,7 @@
11891189
<xs:documentation>The role name to assign.</xs:documentation>
11901190
</xs:annotation>
11911191
</xs:element>
1192-
<xs:element name="query" type="nonEmptyString">
1192+
<xs:element name="query" type="xs:string">
11931193
<xs:annotation>
11941194
<xs:documentation>The LDAP query for this role.</xs:documentation>
11951195
</xs:annotation>

0 commit comments

Comments
 (0)