Issue Details (XML | Word | Printable)

Key: XWIKI-2496
Type: New Feature New Feature
Status: Open Open
Priority: Minor Minor
Assignee: Sergiu Dumitriu
Reporter: Jasper Siepkes
Votes: 1
Watchers: 2
Operations

If you were logged in you would be able to see more operations.
XWiki Core

Single Sign on HTTP Negiotiate login

Created: 23/Jun/08 13:11   Updated: 19/Jan/10 11:57
Component/s: Authentication and Rights Management
Affects Version/s: 1.9 M1
Fix Version/s: Future

File Attachments: 1. Java Source File AppServerTrustedKerberosAuthServiceImpl.java (2 kB)
2. Text File xwiki-core-AppServerTrustedAuthServiceImpl-typo.patch (0.7 kB)
3. Text File xwiki-core-AppServerTrustedAuthServiceImpl-typo.patch (0.7 kB)
4. Text File xwiki-core-AppServerTrustedKerberosAuthServiceImpl.patch (4 kB)
5. Text File xwiki-core-AppServerTrustedKerberosAuthServiceImpl.patch (4 kB)


keywords: patch
Date of First Response: 17/Nov/08 17:07


 Description  « Hide
I needed users within our organization to be able to login to XWiki via HTTP Negotiate. I'm sure this is a requirement for other companies as well.

The easiest way IMHO to do this is to have Apache HTTPD do the heavy lifting with mod_auth_kerb. Implementing Java container/Realm HTTP Negotiate would be considerable more work.

After Apache HTTPD has done the kerberos authentication one would expect to be able to simply use Xwiki's AppServerTrustedAuthServiceImpl as authentication implementation class and be done with it. However in Kerberos the user is authenticated as a principal which looks like this username@REALMNAME.TLD (for example: siepkes@EXAMPLE.COM). The @REALMNAME.TLD part makes it impossible to use AppServerTrustedAuthServiceImpl.

I propose we include a simple class called AppServerTrustedKerberosAuthServiceImpl which chops off the @REALMNAME.TLD part of the principal. This works for me with: MIT-Kerberos, Apache 2 HTTP, mod_auth_kerb, mod_jk and Apache Tomcat 5.5.

Theoretically this class should also work with IIS, mod_jk and Apache Tomcat 5.5, making it possible for Active Directory users to automatically login via SSO. I Haven't tested it, but for as far as I can see this shoud work.



 All   Comments   Change History   FishEye      Sort Order: Ascending order - Click to sort in descending order
Rémy NOËL added a comment - 17/Nov/08 17:07
As I can see, this patch should work but it doesn't consider old domain notations.

my.domain\user has to be considered too in this case.


Jasper Siepkes added a comment - 18/Nov/08 21:06
> my.domain\user has to be considered too in this case.
Is that used as a Kerberos V prinicipal name with Active Directory ? Is it possible to authenticate to Apache with mod_auth_kerb with such a principal name ?

Rémy NOËL added a comment - 21/Nov/08 11:25
> Is that used as a Kerberos V prinicipal name with Active Directory ?
Yes for NT4 compatibility. "@domain" is used for Windows 2000 and later.
> Is it possible to authenticate to Apache with mod_auth_kerb with such a principal name ?
No idea... I use tomcat and JCIFS for NTLM authentication. Anyway, I assume Apache community takes care of backward compatibility .

Stevo Slavic added a comment - 05/Mar/09 17:09
Just attached "AppServerTrustedKerberosAuthServiceImpl-wikiname.patch" which is tested and works with Kerberos 5. It is slightly modified version of original patch, it handles situations where username contains dots. For wikiname conformity, "createUser(String user, XWikiContext context)" method of XWikiAuthServiceImpl has been altered to return wikiname String it already was determining for given username.

This patch also tackles situation when principal is in "domain\username" format - this was not tested.

On xwiki users mailing list ( http://lists.xwiki.org/pipermail/users/2009-March/015403.html ) I've also explained obstacle and solution for initialization of xwiki content using appropriate xar whilst using kerberos authentication.

Second patch fixes only a minor typo in javadoc of AppServerTrustedAuthServiceImpl class.


Alex Dubov added a comment - 12/Mar/09 12:52
After applying this patch to xwiki-core-1.8-rc2 I keep getting the following error:

Wrapped Exception:

java.lang.NoSuchMethodError: com.xpn.xwiki.user.impl.xwiki.AppServerTrustedKerber
osAuthServiceImpl.createUser(Ljava/lang/String;Lcom/xpn/xwiki/XWikiContext;)Ljava
/lang/String;
at com.xpn.xwiki.user.impl.xwiki.AppServerTrustedKerberosAuthServiceImpl.
checkAuth(AppServerTrustedKerberosAuthServiceImpl.java:44)

(rest omitted)

I tried several JREs, as well as renaming the method into something different. I made sure that the changes were applied (line of actual error differs).

There's nothing wrong with the code, as far as I can tell.

May be somebody encountered this issue before or knows what can it be?


Stevo Slavic added a comment - 12/Mar/09 13:32
If you applied patch I've attached, check that XWikiAuthServiceImpl method's "protected void createUser(String user, XWikiContext context) throws XWikiException" return type has been changed to "protected String createUser(String user, XWikiContext context) throws XWikiException" and that at appropriate places wikiname/user gets returned as value of method - this is important as principal username can be incompatible with xwiki, e.g. I've experienced issues if principal username contained dots. I've just used the fact that createUser method already performs username "normalization" to xwiki compatible form, so I just returned the result back to AppServerTrustedKerberosAuthServiceImpl.

This change of XWikiAuthServiceImpl's createUser method is the only change I've done to that class, although patch marks all lines as changed - I presume this is because of different formatter used in original and patched version (tabs, spaces, ...).


Alex Dubov added a comment - 13/Mar/09 06:41
Of course, this was the first item on my checklist.

javap output for AppServerTrustedKerberosAuthServiceImpl:

137: invokevirtual #105; //Method createUser:(Ljava/lang/String;Lcom/xpn/xwiki/XWikiContext;)Ljava/lang/String;

and for corresponding XWikiAuthServiceImpl:

protected java.lang.String createUser(java.lang.String, com.xpn.xwiki.XWikiContext) throws com.xpn.xwiki.XWikiException;

as extracted from actually installed jar file.


Stevo Slavic added a comment - 13/Apr/09 09:48
Attached new patches.

Patch for AppServerTrustedAuthServiceImpl is trivial javadoc typo fix.

In previous kerberos patch, for XWikiAuthServiceImpl class all lines were marked as modified because of tabs/spaces.

These patches work for me since XWiki 1.7.1, and even now with 1.8.1. Can someone else please test, too.

I'd like to have this included in the XWiki asap, so I don't have to build xwiki-core with every new XWiki release.


Jasper Siepkes added a comment - 13/Apr/09 11:23
Hi Stevo,

I made the original hack/quickfix for Kerberos way back. I can see you have been quite busy . Unfortunately I haven't had time (yet) to give your patch a spin.

> I'd like to have this included in the XWiki asap, so I don't have to build xwiki-core with every new XWiki release.

I'm also pro inclusion in xwiki but I don't think you have to recompile xwiki every time a new release comes out. Just put the AppServerTrustedKerberosAuthServiceImpl.java in a seperate jar. I'm still using my original hack/qucikfix: 'AppServerTrustedKerberosAuthServiceImpl.java' in a seperate jar which I place in the /WEB-INF of xwiki.


Stevo Slavic added a comment - 13/Apr/09 13:00
Separate jar would be OK, hadn't I modified XWikiAuthServiceImpl class too - it's createUser returns xwiki valid username.

Thus, one has to, not to build entire jar but rather, in xwiki-core.jar for given release, replace/include changed/new class files. To get class files one has to apply patch to given release sources, and compile the project.


Jasper Siepkes added a comment - 13/Apr/09 13:09
Sorry, I hadn't noticed you also modified XWikiAuthServiceImpl .

Maybe we can then push for inclusion of the patched XWikiAuthServiceImpl first, separately of the Kerberos specific code ?


Sergiu Dumitriu added a comment - 13/Apr/09 13:26
I'll look at the patch today.

Stevo Slavic added a comment - 30/Apr/09 12:29
Alex, I just had same issue when applying patch to xwiki 1.8.2, Eclipse was complaining about assigning void (previous return type of createUser) to a String. With Eclipse 3.4.2 and Subversive 0.7.8 plug-in, applying patch to XWikiAuthServiceImpl just didn't trigger compiling of the class. Triggering compilation did the work for me.

Sergiu, did you have time to look at xwiki-core-AppServerTrustedKerberosAuthServiceImpl.patch? It works with 1.8.2 too. Are there any chances to have that patch applied and included in 1.9 release?


Sergiu Dumitriu added a comment - 01/May/09 01:46
No, I didn't look at it yet. Scheduling for review...

Vincent Massol added a comment - 19/May/09 13:08
Sergiu, tell us if you want to commit in 1.9RC2 but it needs to be done quickly if that's the case

Stevo Slavic added a comment - 19/Jan/10 11:57
Attaching updated patches to latest xwiki release (2.1.1, r26232). Issue is trivial yet more than a year old...