@Darran
So after getting the digest-md5 to work in ejb-security I again tried it in my project code and if I only use ApplicationRealm there it works but when using it as part of a distributed-realm it did not work. I probably do not need a distributed-realm but the main issue that I started with was how to use the user provided password encrypted with the ldap-realm and that I still cannot get to work. Here is the config from my standalone.xml:
<sasl-authentication-factory name="application-sasl-authentication-ldap" sasl-server-factory="configured" security-domain="ApplicationDomain">
<mechanism-configuration>
<mechanism mechanism-name="DIGEST-MD5">
<mechanism-realm realm-name="CachedLdapRealm"/>
</mechanism>
<mechanism mechanism-name="PLAIN">
<mechanism-realm realm-name="CachedLdapRealm"/>
</mechanism>
</mechanism-configuration>
</sasl-authentication-factory>
<security-domain name="ApplicationDomain" default-realm="CachedLdapRealm" permission-mapper="default-permission-mapper">
<realm name="CachedLdapRealm" role-decoder="from-roles-attribute"/>
</security-domain>
<ldap-realm name="LdapRealm" dir-context="ldap-connection" direct-verification="true">
<identity-mapping rdn-identifier="${env.AD_IDENTIFIER}" search-base-dn="${env.AD_SEARCH_BASE}">
<attribute-mapping>
<attribute from="${env.AD_ROLE_ATTRIBUTE}" to="Roles" filter="(${env.AD_IDENTIFIER}={0})" filter-base-dn="${env.AD_FILTER_BASE}"/>
</attribute-mapping>
</identity-mapping>
</ldap-realm>
<caching-realm name="CachedLdapRealm" realm="LdapRealm"/>
<dir-contexts>
<dir-context name="ldap-connection" url="${env.AD_HOST}" principal="CN=${env.AD_PRINCIPAL}, ${env.AD_SEARCH_BASE}">
<credential-reference clear-text="${env.AD_CREDENTIAL}"/>
</dir-context>
</dir-contexts>
Config that work in the client:
ejbConfig = AuthenticationConfiguration.empty()
.usePassword(password)
.usePrincipal(principal)
.useAuthorizationName(userName)
.useAuthorizationPrincipal(principal)
.setSaslMechanismSelector(SaslMechanismSelector.fromString("PLAIN"))
.useRealm(realm);
Not working:
ejbConfig = AuthenticationConfiguration.empty()
.useCredential(credential)
.usePrincipal(principal)
.useAuthorizationName(userName)
.useAuthorizationPrincipal(principal)
.setSaslMechanismSelector(SaslMechanismSelector.fromString("DIGEST-MD5"))
.useRealm(realm);
I get:
2022-03-04 19:50:59,818 TRACE [org.wildfly.security] (default task-1) Handling PasswordCallback: PasswordCredential may not be supported
2022-03-04 19:50:59,818 TRACE [org.wildfly.security.sasl.digest] (default task-1) SASL Negotiation Failed
2022-03-04 19:50:59,818 TRACE [org.jboss.remoting.remote.server] (default task-1) Server sending authentication rejected: javax.security.sasl.SaslException: ELY05051: Callback handler does not support credential acquisition [Caused by org.wildfly.security.auth.callback.FastUnsupportedCallbackException: javax.security.auth.callback.PasswordCallback@5b87dd4]
Any ideas?
/Tomas