Search code examples
phpgoogle-oauthhybridauthcodeigniter-a3m

HybridAuth w/ Google redirects badly in codeigniter-a3m


I'm using the dev version (2.0) of A3M for CodeIgniter to add secure authentication to my app. The auth process (which uses HybridAuth 2.2.0-dev) seems to go well since the logs show:

(
    [hauth_return_to] => https://mywebsite.com/account/connect/Google
    [hauth_token] => uhas9b51ajhlehkbo1fehj79t0
    [hauth_time] => 1405629149
    [login_start] => https://mywebsite.com/account/connect_end?hauth.start=Google&hauth.time=1405629149
    [login_done] => https://mywebsite.com/account/connect_end?hauth.done=Google
)

But it redirects me to a page at this URL:

https://mywebsite.com/account/connect_end?hauth.start=Google&hauth.time=1405629255

with this content:

HybridAuth
Open Source Social Sign On PHP Library. 
hybridauth.sourceforge.net/

And does not complete login or account linking. I've tried changing my redirect_uri in the Google Developer Console to both '/account/connect_end' and '/account/connect/Google' with identical results. How can I get it to connect?


Solution

  • OK, although it looks like a configuration file problem or a bug, this is actually a problem with the URL handling in the web server. I added this rule to NGINX:

    location / {
    
        try_files $uri $uri/ /index.php;
        if (!-e $request_filename){
            rewrite ^(.*)$ /index.php?/$1 last;
        }
    }