I'm trying to integrate simple OpenID authentication through Google accounts. I'm using omniauth gem and on my local development system (Win7, ruby 1.8.7-p302, rails 2.3.8, omniauth 0.1.5) everything works nice.
The problem shows it's face when I deploy it to my hosting (HostGator). The app (mongrel) starts at port 12002 and through HostGator's cPanel it's configured to be rewritten from one of subdomains:
RewriteCond %{HTTP_HOST} ^subdomain.mycompany.com$ [OR]
RewriteCond %{HTTP_HOST} ^www.subdomain.mycompany.com$
RewriteRule ^(.*)$ "http\:\/\/127\.0\.0\.1\:12002\/$1" [P,L]
When browser goes /auth/open_id it's redirected to Google for authorization but it's return_to address is subdomain.mycompany.com:12002 which of course is incorrect because Apache doesn't listen on 12002. I've managed to monkey patch OmniAuth::Strategies::OpenID and Rack::OpenID so they assemble address without port BUT now on the final stage after user access confirmation if falls into:
Routing Error
No route matches "/403.shtml" with {:method=>:get}
I guess the problem is what my site's address is encoded (some kind of hash) at other authorization request parameter to avoid
The port issue is because of the the way RACK request computes the port. Here is the patch
This is the way rails ActionController::Request computes the port.
Hope this helps
Well...
The 403 error was because hosting security rules were so strict what Google's OpenID response (long enough to be suspicious) was rejected. Resolved by hosting support.
To resolve the problem with port number within return_to parameter (addressed by freiwillen) I've made the following (monkey path) initializer:
I hope someone will propose more elegant solution.
In the most recent version of Omniauth (0.2.0.beta4) you can specify
full_host
as a config option and set it to be evaluated at each request, or just use a fixed value.Example (rails):