mirror of https://github.com/OpenIdentityPlatform/OpenDJ.git

Gaetan Boismal
06.18.2016 79811e7a2c59f9e4b237043466b736b5ece294dc
OPENDJ-3067 Use curly brace notation in all templates for consistency

Since that the oauth2.authzIdTemplate field must contain some
placeholders like {uid} or {userName/0}, others template fields with
only one "%s" make our configuration inconsistent.
This commit replace the %s placeholders in basic.simple.baseDNTemplate,
basic.sasl-plain.authzIdTemplate and search.filterTemplate.
2 files modified
28 ■■■■■ changed files
opendj-rest2ldap-servlet/src/main/webapp/WEB-INF/classes/opendj-rest2ldap-config.json 18 ●●●● patch | view | raw | blame | history
opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAPHttpApplication.java 10 ●●●● patch | view | raw | blame | history
opendj-rest2ldap-servlet/src/main/webapp/WEB-INF/classes/opendj-rest2ldap-config.json
@@ -103,10 +103,10 @@
                // If missing, "bind" factory will be used.
                "ldapConnectionFactory": "bind",
                // The Bind DN Template containing a single %s which will be replaced by the authenticating
                // user's name. (i.e: uid=%s,ou=People,dc=example,dc=com)
                // If missing, "%s" is used.
                "bindDNTemplate": "uid=%s,ou=People,dc=example,dc=com"
                // The Bind DN Template containing a single {username} which will be replaced by the authenticating
                // user's name. (i.e: uid={username},ou=People,dc=example,dc=com)
                // If missing, "{username}" is used.
                "bindDNTemplate": "uid={username},ou=People,dc=example,dc=com"
            },
            // Bind to the LDAP server using a SASL Plain request
@@ -115,9 +115,9 @@
                // If missing, "bind" factory will be used.
                "ldapConnectionFactory": "bind",
                // Authentication identity template containing a single %s which will be replaced by the authenticating
                // user's name. (i.e: u:%s)
                "authzIdTemplate": "u:%s"
                // Authentication identity template containing a single {username} which will be replaced by the authenticating
                // user's name. (i.e: u:{username})
                "authzIdTemplate": "u:{username}"
            },
            
            // Bind to the LDAP server using the resulting DN of a search request. 
@@ -130,11 +130,11 @@
                // If missing, "bind" factory will be used.
                "bindLDAPConnectionFactory": "bind",
            
                // The %s filter format parameters will be substituted with the client-provided username,
                // The {username} filter format parameters will be substituted with the client-provided username,
                // using LDAP filter string character escaping.
                "baseDN"         : "ou=people,dc=example,dc=com",
                "scope"          : "sub", // Or "one".
                "filterTemplate" : "(&(uid=%s)(objectClass=inetOrgPerson))"
                "filterTemplate" : "(&(uid={username})(objectClass=inetOrgPerson))"
            }
            // TODO: support for HTTP sessions?
        },
opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Rest2LDAPHttpApplication.java
@@ -387,14 +387,14 @@
    private AuthenticationStrategy buildSimpleBindStrategy(final JsonValue config) {
        return newSimpleBindStrategy(getConnectionFactory(config.get("ldapConnectionFactory")
                                                                .defaultTo(DEFAULT_BIND_FACTORY).asString()),
                                     config.get("bindDNTemplate").defaultTo("%s").asString(),
                                     parseUserNameTemplate(config.get("bindDNTemplate").defaultTo("%s")),
                                     schema);
    }
    private AuthenticationStrategy buildSASLBindStrategy(JsonValue config) {
        return newSASLPlainStrategy(
                getConnectionFactory(config.get("ldapConnectionFactory").defaultTo(DEFAULT_BIND_FACTORY).asString()),
                schema, config.get(AUTHZID_TEMPLATE).defaultTo("u:%s").asString());
                schema, parseUserNameTemplate(config.get(AUTHZID_TEMPLATE).defaultTo("u:%s")));
    }
    private AuthenticationStrategy buildSearchThenBindStrategy(JsonValue config) {
@@ -405,6 +405,10 @@
                        config.get("bindLDAPConnectionFactory").defaultTo(DEFAULT_BIND_FACTORY).asString()),
                DN.valueOf(config.get("baseDN").required().asString(), schema),
                SearchScope.valueOf(config.get("scope").required().asString().toLowerCase()),
                config.get("filterTemplate").required().asString());
                parseUserNameTemplate(config.get("filterTemplate").required()));
    }
    private String parseUserNameTemplate(final JsonValue template) {
        return template.asString().replace("{username}", "%s");
    }
}