AEM 61 - Creating Readable User Name Nodes in CRX

Goal


For security reasons, AEM 61 is shipped with randomized authorizable node name creator, details here; The node name length can be configured in service http://localhost:4502/system/console/configMgr/org.apache.jackrabbit.oak.security.user.RandomAuthorizableNodeName

This post is on creating meaningful node names for new users

Demo | Source Code (Not Package Install)


Product



Extension



Solution


1) Create a OSGI service apps.experienceaem.auth.ReadableAuthNodeName implementing org.apache.jackrabbit.oak.spi.security.user.AuthorizableNodeName, add the following code

package apps.experienceaem.auth;

import org.apache.felix.scr.annotations.Component;
import org.apache.felix.scr.annotations.Service;
import org.apache.jackrabbit.oak.spi.security.user.AuthorizableNodeName;

@Component
@Service(AuthorizableNodeName.class)
public class ReadableAuthNodeName implements AuthorizableNodeName {
    @Override
    public String generateNodeName(String authorizableId) {
        return (authorizableId.length() > 3 ? authorizableId.substring(0, 3) : authorizableId)
                    .replaceAll("[^A-Za-z0-9]", "-");
    }
}



No comments:

Post a Comment