I would like to allow users to sign up using a on SASL based, but non-standard conforming authentication method by using public/private key method. Development of the authorization process isn’t any problem. The issue is how to catch the auth- and response- queries when the mechanism is set to something line “X-MY-PLATFORM”.
Using AuthProvider is not an option for that kind of authentication, since it doesn’t use a password. I’ve tried to implement a packet filter using PacketInterceptor. But I’ve had to learn that is not possible since the PacketInterceptor only filters IQ, MESSAGE and PRESENCE packets. AUTH and RESPONSE packets are immediatly routed to the SASLMechanism.
Does anybody has a workarround for authentication processes when there is no username/password combination used?
@Openfire Devs: It would be very, very helpful if you could make developing custom authentication processes easier in a future Openfire release.
We need this, too. Currently we have a ugly workaround for this. Roughly:
login with ANONYMOUS.
Do a RPC call to Openfire to request the Openfire password, which is returned encrypted with user’s public key.
decrypt the password with private key and login in with DIGEST-MD5.
I’ve checked Openfire’s source code and saw that appearently you can set your own set of mechanisms:
String available = JiveGlobals.getProperty(“sasl.mechs”);
But it’s rechecked to be in a predefined array, with a nice comment:
// Check that the mech is a supported mechansim. Maybe we shouldnt check this and allow any?
if (mech.equals(“ANONYMOUS”) ||
mech.equals(“PLAIN”) ||
mech.equals(“DIGEST-MD5”) ||
mech.equals(“CRAM-MD5”) ||
mech.equals(“GSSAPI”) ||
mech.equals(“EXTERNAL”) ||
mech.equals(“JIVE-SHAREDSECRET”))
{
Log.debug(“SASLAuthentication: Added " + mech + " to mech list”);
mechanisms.add(mech);
}
If I think about it, it might be enough, to remove the above check and register your own SaslServer via java.security.Provider in a plugin (and also fill the sasl.mechs property).
Really like your idea. But I don’t like manipulating Openfire code directly. It would be great if the Openfire developers would accept your idea, since it wouldn’t require much change anyway.
Yes it work. I’ve had to implement SaslServer, SaslServerFactory and Provider. Then using Sasl.addProvider() and SASLAuthentication.addMechanism() and everything works fine. There is even complete error handling implemented in Openfire for custom mechanisms, I don’t have any idea why these fixed-code check is added there and there seem to be no reason why not removing it.
I’ve added the whole stuff to a plugin and tested dynamic adding/removing for enable/disable plugin too. I’ve also checked how the server behaves when using non-existing (=auth failed+one INFO debug line of someone tried to use XYZ for auth), broken (=auth failed+stack trace in log) and blocking (ends in timeout for the client session) auth mechanism and everything seems to get handled like I would have expected it.
When implementing a custom SaslServer the easiest way is to look how ClearspaceSaslServer is implemented and do exactly the same.
But since I don’t like to use customized Openfire versions and instead like to use plugins for such stuff I hope the check will get removed in the next update of Openfire since there seems to be any reason anyway.
I am trying to build a custom authentication mechanism, since openfire supports only Anonymous and Plain when configure custom authenitcation provider.
I am looking forward to try the approach proposed by Michael. Please guide me in building a custom mechanism.