[xwiki-users] Single sign on
I have two different applications - myProject and Xwiki running on tomcat server. I have iframe in myProject that displays the xwiki.I made the look and feel much similiar so that it feel like same app to the user. I'm using REST APIs to communicate between two apps. I've made the application such that if the user is created in myProject, the same user gets created in XWiki too. Now, I wanted to make the application such that if the user logs in myProject, he/she will be automatically logged in the xwiki. Can this be achieved? Any help will be greatly appreciated. Thankyou in advance, xManish -- View this message in context: http://xwiki.475771.n2.nabble.com/Single-sign-on-tp5299320p5299320.html Sent from the XWiki- Users mailing list archive at Nabble.com.
On 07/15/2010 11:04 PM, xManish wrote:
I have two different applications - myProject and Xwiki running on tomcat server. I have iframe in myProject that displays the xwiki.I made the look and feel much similiar so that it feel like same app to the user. I'm using REST APIs to communicate between two apps. I've made the application such that if the user is created in myProject, the same user gets created in XWiki too.
Now, I wanted to make the application such that if the user logs in myProject, he/she will be automatically logged in the xwiki. Can this be achieved? Any help will be greatly appreciated.
XWiki authenticates using cookies. You could duplicate the code that adds the right cookies (com.xpn.xwiki.user.impl.xwiki.MyPersistentLoginManager#rememberLogin) into your application, and XWiki will automatically see them and login the right user. Don't forget to remove those cookies on logout (#forgetLogin). -- Sergiu Dumitriu http://purl.org/net/sergiu/
Sergiu Dumitriu-2 wrote:
XWiki authenticates using cookies. You could duplicate the code that adds the right cookies (com.xpn.xwiki.user.impl.xwiki.MyPersistentLoginManager#rememberLogin) into your application, and XWiki will automatically see them and login the right user. Don't forget to remove those cookies on logout (#forgetLogin).
Hi, Thankyou for the reply. I tried to reuse the code from (com.xpn.xwiki.user.impl.xwiki.MyPersistentLoginManager#rememberLogin) I found that it requires two variables to be set beforehand, which I believe would come from xwiki.cfg. These are this.secretkey and this.validationkey So, I tried to instantiate them myself in myProject for secretkey, I did following byte[] theKey = stringToHex("secret").getBytes(); KeySpec ks = new DESKeySpec(theKey); SecretKeyFactory kf = SecretKeyFactory.getInstance("DES"); this.secretKey = kf.generateSecret(ks); Since validationkey was just a string, I did following this.validationKey = "validt"; Then I edited the xwiki.cfg file of my xwiki installation xwiki.authentication.validationKey=validt xwiki.authentication.encryptionKey=secret After loggin into the system, I found that cookies are set. However that user aren't automatically logged in xwiki. I'm sure I've been missing something in the process. Can you please looked into it and identify it. Thankyou, Manish -- View this message in context: http://xwiki.475771.n2.nabble.com/Single-sign-on-tp5299320p5303069.html Sent from the XWiki- Users mailing list archive at Nabble.com.
On 07/16/2010 07:48 PM, xManish wrote:
Sergiu Dumitriu-2 wrote:
XWiki authenticates using cookies. You could duplicate the code that adds the right cookies (com.xpn.xwiki.user.impl.xwiki.MyPersistentLoginManager#rememberLogin) into your application, and XWiki will automatically see them and login the right user. Don't forget to remove those cookies on logout (#forgetLogin).
Hi, Thankyou for the reply. I tried to reuse the code from (com.xpn.xwiki.user.impl.xwiki.MyPersistentLoginManager#rememberLogin) I found that it requires two variables to be set beforehand, which I believe would come from xwiki.cfg. These are this.secretkey and this.validationkey So, I tried to instantiate them myself in myProject for secretkey, I did following byte[] theKey = stringToHex("secret").getBytes(); KeySpec ks = new DESKeySpec(theKey); SecretKeyFactory kf = SecretKeyFactory.getInstance("DES"); this.secretKey = kf.generateSecret(ks);
Since validationkey was just a string, I did following this.validationKey = "validt";
Then I edited the xwiki.cfg file of my xwiki installation xwiki.authentication.validationKey=validt xwiki.authentication.encryptionKey=secret
After loggin into the system, I found that cookies are set. However that user aren't automatically logged in xwiki.
I'm not sure what the format of the keys should be, but trying your keys ends up with an error in the logs: Error: java.security.InvalidKeyException: Wrong key size Actually, it says this in xwiki.cfg, above the keys: #-# Cookie encryption keys. You SHOULD replace these values with any random string, #-# as long as the length is the same. So you should generate keys with 32 characters.
I'm sure I've been missing something in the process. Can you please looked into it and identify it.
-- Sergiu Dumitriu http://purl.org/net/sergiu/
Sergiu Dumitriu-2 wrote:
Actually, it says this in xwiki.cfg, above the keys:
#-# Cookie encryption keys. You SHOULD replace these values with any random string, #-# as long as the length is the same.
So you should generate keys with 32 characters.
I mis-interpreted it. I thought it meant there could be any two strings as long as the length of those two strings are same. Anyways, I changed it to the default key provided by xwiki and followed the same procedure that I did earlier using those keys. But it still isn't working. -Manish -- View this message in context: http://xwiki.475771.n2.nabble.com/Single-sign-on-tp5299320p5303683.html Sent from the XWiki- Users mailing list archive at Nabble.com.
I got it right. For some reason, I thought I had to convert the key to HEX. I was wrong. I changed the code like below and it worked... :) for secretkey, String secret = "titititititititititititititititi"; (the one from xwiki.cfg) byte[] theKey = secret.getBytes(); KeySpec ks = new DESKeySpec(theKey); SecretKeyFactory kf = SecretKeyFactory.getInstance("DES"); this.secretKey = kf.generateSecret(ks); Thanks, Manish -- View this message in context: http://xwiki.475771.n2.nabble.com/Single-sign-on-tp5299320p5309729.html Sent from the XWiki- Users mailing list archive at Nabble.com.
participants (2)
-
Sergiu Dumitriu -
xManish