I was having a funny issue with sso. Although login/logout process was succesful, whenever I tried to login from an internal page on a client domain es. www.myclientdomain.com/my-page the controller returned a wrong path in the following form: www.myclientdomain.com/%3Fq%3Dmy-page.

After some code crawling, just logged onto the controller and found out that simply I hadn't configured simplified URLs. So, BOTH CONTROLLER AND CLIENT MUST HAVE SAME URL PATH CONFIGURATION, otherwise, like in my case controller will return inconsistent values.