I recently ran into a situation where a client wanted to place their public facing ASP.NET website behind Oracle SSO to allow their customers to log in via their existing Oracle SSO accounts, yet also allow anonymous users to use the application without logging in. We could have done a simple LDAP integration, but the client also wanted users to not have to log into the application if they’re already logged into their Oracle Portal account.
First step, we had to determine how to get Oracle SSO running on Oracle Application Server (OAS) to protect an application running on a separate IIS web server. In order for an ASP.NET application to be able to get user credentials from Oracle SSO, Oracle SSO has to run “in front of” your application – i.e. something has to intercept the browser request on the way to your web app, decrypt their SSO session cookie, and inject an HTTP header containing the the user’s username that your ASP.NET application can read. There are two ways to accomplish this – Apache Reverse Proxying and the Oracle SSO IIS Plug-in.
To preface, Apache Reverse Proxying will route all the calls to your application through Apache first. The other option, the Oracle SSO IIS plug-in is installed on your IIS server, requests are sent directly to the IIS web server, and the requests are intercepted and security is handled by the Oracle plugin.
Doing a simple find and replace on the .axd paths works fine for regular postback responses to fix the bad paths, but fails with ASP.NET AJAX partial-page updates. You can find and replace in the partial-page updates, but then it will throw off the field lengths in the pipe-separated data that is sent back to the browser. Thus, you need to actually find and rewrite the field lengths on the fly as well whenever you do a replace on the .axd paths. You can see the implementation of this in the ReverseProxyPathFixModule.cs below – it is a little scary, and I’m sure it isn’t full proof because the partial page responses are chunked upon being sent back to the browser. If there was an .axd path in between chunks, it wouldn’t be replaced – but I never saw this happen.
The most relevant portions of the code below are the Write() methods of PageFilter and PartialPageFilter – they do all the work. The rest of the code is just overridden Stream methods.
After implementing the custom HttpModule, the application was working almost perfectly behind the Reverse Proxy.
For the next hurdle, we couldn’t find any way to have Oracle SSO protect a resource in IIS (or even running in OAS for that matter) while allowing both anonymous and authenticated access. There isn’t any built-in way to allow anonymous access to an application while it is protected by Oracle SSO. After much research and reading this Extending Oracle SSO presentation and this Integration with Third-Party Access Management Systems help documentation from Oracle, we decided to create a custom Oracle SSO module that would “authenticate” a user and pass them to the application as the Oracle Portal “PUBLIC” account if they weren’t already logged in to SSO. The implementation of this plugin is fairly simple – it’s a Java class that inherits from the default Oracle SSO module (SSOServerAuth) and implements the IPASAuthInterface interface. The code simply checks the user’s cookies on the request – if the user has an Oracle Portal cookie, perform the authentication from the base class by calling super.authenticate. If the user doesn’t have a portal cookie, pass them on to the application and “authenticate” them as the PUBLIC user account. This is definitely a hack, but it works pretty well. See the implementation of the MixedAuthentication below.
Compilation of the code is a little tricky, you need to include ipastoolkit.jar, ossocls.jar, and servlet.jar in your classpath. The ossocls.jar isn’t usually included or detailed in the documentation because most Oracle SSO plugins don’t inherit from SSOServerAuth (it isn’t required), but rather just implement IPASAuthInterface. Deployment is also tricky, fortunately I found this blog post ‘Adding reCAPTCHA to Oracle SSO‘ that detailed how the plugin should be deployed to OC4J_SECURITY container, rather than the standard $ORACLE_HOME/sso/plugins location.
More hurdles! After successfully setting up our custom authentication plugin, we couldn’t figure out how to have our reverse proxy’d application use the custom plugin without it also affecting the client’s Oracle Portal installation. After we would set the reverse proxy path to use the custom plugin, we would see strange behavior in the Oracle Portal even though portal would be set to use the standard MediumSecurity and our reverse proxy path would be set to use our custom ‘MixedSecurity’ setting.
This is how we tried to set up our Oracle SSO policy.properties file:
#add our custom security level. MixedSecurity = 70 #keep the default authentication level so as to not affect oracle portal security. DefaultAuthLevel = MediumSecurity #set our custom app behind reverse proxy to use our new custom security level. oas.client.com/iissite\:80 = MixedSecurity #not sure if you need the path on OAS or the reverse proxy site. also tried it this way.. didn't work. iis.client.com\:80 = Mixed Security #set the plugin class for our custom security level MixedSecurity = com.client.authentication.MixedAuthentication
No matter what we tried with the SSO configuration we couldn’t get our application behind the reverse proxy to be protected by our custom plugin without also affecting the security of Oracle Portal. If anyone knows how to actually do that, I’d be interested to hear where we went wrong in the comments. Unfortunately, this meant that the work with the custom HttpModule, setting up the reverse proxy, etc. was all for naught. We had to install the Oracle SSO IIS plugin. This plugin is somewhat of a beast – the installation and configuration is one of the most complicated and least user-friendly I’ve ever encountered and involves creating registry entries manually, providing many opportunities to make mistakes along the way.
Either way, after installing the IIS plugin everything worked fairly smoothly. One thing to note – if you want to redirect the user from your ASP.NET application to log in to their actual Oracle SSO account rather than the PUBLIC account, you need to delete the user’s cookie that will look something like IAS_IDXXXXXX – this will “log out” the user from the PUBLIC account. If the user isn’t logged out of the PUBLIC account before hitting the SSO logon page, they’ll be automatically redirected (to the url provided in the p_requested_url parameter when sending the user to the SSO logon page) when they hit the page because they’re actually already logged in to the PUBLIC account.
One remaining problem, the Oracle SSO IIS plug-in manages to randomly crash the worker process with an error like:
Faulting application w3wp.exe, version 6.0.3790.3959, stamp 45d6968e, faulting module oracle_osso.dll, version 0.0.0.0, stamp 41775fa1, debug? 0, fault address 0×00002454.
Checking the SSO plug-in log files yields nothing out of the ordinary either so this has been pretty difficult to track down, we still haven’t found any solution for this problem. If anyone knowledgeable on the IIS or Oracle SSO side of things has some ideas or has seen this before, feel free to let me know in the comments.
Finally, after your ASP.NET application is safely behind Oracle SSO you can determine the logged in user’s username by checking the OSSO-USERNAME header like so:
After that, the user’s username from Oracle SSO will come over on the HTTP headers on every request to your application.