Skip to content

Commit 87058e2

Browse files
author
Vladimir Kotal
committed
- extend the regex used for LDAP user matching
- bump log levels used for LDAP query errors
1 parent dced61b commit 87058e2

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

plugins/LdapPlugin/src/opengrok/auth/plugin/LdapUserPlugin.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public class LdapUserPlugin extends AbstractLdapPlugin {
4747
protected static final String OBJECT_CLASS = "objectclass";
4848

4949
private String objectClass;
50-
private Pattern usernameCnPattern = Pattern.compile("(cn=[a-zA-Z_]+)");
50+
private final Pattern usernameCnPattern = Pattern.compile("(cn=[a-zA-Z0-9_-]+)");
5151

5252
private boolean isAlphanumeric(String str) {
5353
for (int i = 0; i < str.length(); i++) {
@@ -124,25 +124,25 @@ public void fillSession(HttpServletRequest req, User user) {
124124
String filter = getFilter(user);
125125
if ((records = getLdapProvider().lookupLdapContent(null, filter,
126126
new String[]{"uid", "mail", "ou"})) == null) {
127-
LOGGER.log(Level.FINER, "failed to get LDAP contents for user '{0}' with filter '{1}'",
127+
LOGGER.log(Level.WARNING, "failed to get LDAP contents for user '{0}' with filter '{1}'",
128128
new Object[]{user, filter});
129129
return;
130130
}
131131

132132
if (records.isEmpty()) {
133-
LOGGER.log(Level.FINER, "LDAP records for user {0} are empty",
133+
LOGGER.log(Level.WARNING, "LDAP records for user {0} are empty",
134134
user);
135135
return;
136136
}
137137

138138
if (!records.containsKey("uid") || records.get("uid").isEmpty()) {
139-
LOGGER.log(Level.FINER, "uid record for user {0} is not present or empty",
139+
LOGGER.log(Level.WARNING, "uid record for user {0} is not present or empty",
140140
user);
141141
return;
142142
}
143143

144144
if (!records.containsKey("mail") || records.get("mail").isEmpty()) {
145-
LOGGER.log(Level.FINER, "mail record for user {0} is not present or empty",
145+
LOGGER.log(Level.WARNING, "mail record for user {0} is not present or empty",
146146
user);
147147
return;
148148
}

plugins/LdapPlugin/test/opengrok/auth/plugin/LdapUserPluginTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void getFilterTest1() {
8888
String cl = "posixUser";
8989
params.put(LdapUserPlugin.OBJECT_CLASS, (Object) cl);
9090
plugin.load(params);
91-
String cn = "cn=foo";
91+
String cn = "cn=foo-foo_bar1";
9292
User user = new User(cn + ",l=EMEA,dc=foobar,dc=com", "id", null, false);
9393
String filter = plugin.getFilter(user);
9494
Assert.assertEquals("(&(" + LdapUserPlugin.OBJECT_CLASS + "=" + cl + ")(" + cn + "))",

0 commit comments

Comments
 (0)