Username in HTTP Header for SSO

I am looking to add single sign on (SSO) to one of my web applications. I don't want anything heavy at the moment, I just want to know the userId of the logged in user, without the need for them to enter a username.

The web app is an internal application, so I can guarantee they are coming from a Windows PC etc.

I have looked at jCIFS, but this doesn't seem to be supported any more, and recommends a commercial product.

I have also looked at WAFFLE, but I am building SSO for a playframework application, which does not use a Servlet stack, so I can't make use of the SecurityFilter. I have tried to make sense of the WindowsLoginModule, but couldn't really understand what I had to do to implement it.

Is it possible to just get the username from the HTTP header, or does it require some negotiation first before it will post the header?


You want the windows user to automagically login to your intranet webapp. So the user accounts would sit in an active directory and the usual microsoft way would be to use a protocol like NTML oder Kerberos. Applications are generally advised not to use NTLM, although there are enterprises still using NTML (and jCIFS) for SSO.

A quick search on Kerberos and Java showed this article. It seems to depend on the Java EE stack (JAAS).

For a more stripped down approach: Usually, you cannot sent the username in a http request in a portable way. With ActivX you could do:

var wshshell=new ActiveXObject("");
var username=wshshell.ExpandEnvironmentStrings("%username%");

On the server side, you can parse the http header and extract the username with your technology of choice.

Well, security doesn't matter in your playframework application? Why don't you use long-living cookies?

Hope it helps!

In an intranet context with ActiveDirectory and workstations registered in the domain, the HTTP SPNEGO Negotiation support is the best option. But it requires specific skills around ActiveDirectory and Java Kerberos implementation.

Spring Security provides implementation and documentation to set it up. But Secure.Security is not designed to support token-based authentication like HTTP Negotiation. So using Spring Security will require a specific integration module.

Other options are OpenID and shibboleth but both requires a dedicated server, which can be configured to do SPNEGO itself. Thanks to available Play modules, integration in your application will be easier.

The only way to get the username in an HTTP header without client-side complex and unsecure/unreliable tweaks is to use an authentication proxy between browsers and your application server. Most of these proxies also support Kerberos SPNEGO as authentication mean.

Non-heavy answer

It sounds like it should be possible to get your ops team to implement a Group Policy which will send the logged-in username down the wire as an HTTP Header.

Otherwise, you're correct in your assumption that there is some sort of negotiation "dance" between IE and your server. See here. Perhaps you can fake this dance in your Play code.

Heavy answer

I know jCIFS and this example uses servlets and filters, but the important bits of code can be extracted and a custom Play Authenticator can be built (I can paste a Scala example override of play.api.mvc.Security.Authenticated , but your answer is tagged Java). You only need the request headers (not body) so it should be doable in an authenticator.

PS jCIFS seems to have had an update since your post, so I'm presuming you'd reconsider using hacking it. I'm wary of unmaintained libraries too, but sometimes they just reach a maturity and stability which alleviates the need for any more updates.

Active Directory uses Kerberos, so all logged in users should have a kerberos ticket. A fast google found this:

If you want the windows logon details, I think it's your only option.

You can try to use Shiro for enabling SSO in your application. Shiro id independent of the servlets and since your framework does not support Servlets you can very easily go for Shiro.

You can create a Realm where you define the hashPassword.

You can configure the username and the hashPassword and ask the shiro to authenticate your user with the hashPassword.

You will then assign role for the user which will serve your purpose of SSO.

You can authenticate user for more than one application and hence when user logs into another application the shiro has already authenticated you and hence it will straight away log you inside the application..

You can go through the shiro documentation(exhaustive and you should be able to configure it on first go) from the following link:-

It provides you many out of the box functionality for authenticating and authorization along with security and Cryptography modules.

The username isn't sent in the header. Even if it was this shouldn't be relied upon as a savvy user could fake the values.

If NTLM would be a valid option for you Jespa might be a good alternative to JCIFS. Jespa (unlike JCIFS) supports NTLM v2, among other things. The limited version of it (up to 25 users) is free.

You can always get any header from filter. See javadoc for HttpServletRequest.

Need Your Help

Bash recursive similarities between directories content

linux bash recursion compare diff

I am looking for a bash command/script that will do the following:

Apache 2.4 not creating min spare threads which we have defined

multithreading performance apache worker apache2.4

We have a optimized Apache 2.2 setting which works fine, but after upgrading to Apache 2.4 it seems not reflecting. Both Apache were enabled with worker module, have shared the details below.