I feel like a freaking idiot today as I’m working on some modifications to the mod-isapi Apache module for Web Connection. After screwing around with trying to find a solution to the Basic Authentication problem I’ve finally thrown in the towel and decided I’m going to have to fix this the hard way right at the ISAPI module level.
Apache apparently doesn’t support automatic Authentication for anything but file based security - it doesn't automatically validate auth requests made from code. And to make things worse throws out the Authentication in the case of Basic Authentication (this is actually hardcoded into server with a #Define switch - talk about heavy handed behavior!)
I’ve tried to work around this in some way by using script mappings to force authentication but Apache behaves terribly unpredictably when dealing with script routings. So the only way to get this to work is to hack the isapi module itself.
Ok, I figured out how to get the headers (thanks to Christof Wollenhaupt from Prolib) and re-write the server variables as needed. My thought here is basically to read the incoming header check if it’s basic auth and if the user is not already validated by Apache try to authenticate the user using Windows Authentication. The end result here would be the same behavior that you see in IIS ISAPI extensions. The code for this is not that tough and I got everything to compile just fine at the moment.
Unfortunately I needed to bring in some external code for Base64 decoding the Auth headers and I can not for the life of me to get the project to link now. I’m not a C++ guy as it is and project settings and nested include files give me one hell of a headache <g>, but usually I can figure things out. Not this time.
Here’s the scenario:
I have the original ISAPI mod code which sits in a separate project underneath the main Apache build. It has a single C source file. My Base64 code is just a separate C++ class which has two simple functions that expose decoding and encoding of Base64:
DWORD Base64StringEncode(char *lcInput, DWORD dwInputSize, char *lcOutput );
DWORD Base64StringDecode( char *lcInput,DWORD dwInputSize);
The ISAPI module imports the header just fine and compiles just fine as does my source file. However, the linker complains:
mod_isapi error LNK2019: unresolved external symbol _Base64StringDecode referenced in function _isapi_handler
It can’t find my function and thinks it’s external. But it’s obviously in the same project and compiling just fine, so why is it not finding it? It looks like it might be a calling convention problem but I tried changing the calling convention to my method but had no luck there either.
Anybody have any ideas at what to look at? This is driving me nuts…