Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RoutingError issue in production env only, when getting /auth/any_provider #244

Closed
elmatou opened this issue Mar 29, 2011 · 10 comments
Closed
Labels
Milestone

Comments

@elmatou
Copy link

elmatou commented Mar 29, 2011

I there,
Trying to setup (Running Rails 2.3.11 and Ruby 1.8.7, Omniauth v0.1.6 & tested with 0.2.0 too) this shining gem (thank a lot for your work), I had a new issue after deploying.
The environment initializers are almost defaults one. I had exception rescue strategy, but I disabled it.
My issue is quite simple :
when calling /auth/any_provider a RoutingError is raised (it is quite normal as I understand it), but omniauth is not triggered and no redirection shown then the 404 page is rendered.

ActionController::RoutingError (No route matches "/auth/google_apps" with {:method=>:get}):
  warden (0.10.7) lib/warden/manager.rb:35:in `call'
  warden (0.10.7) lib/warden/manager.rb:34:in `catch'
  warden (0.10.7) lib/warden/manager.rb:34:in `call'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/strategy.rb:54:in `call!'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/strategy.rb:22:in `call'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/strategy.rb:54:in `call!'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/strategy.rb:22:in `call'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/strategy.rb:54:in `call!'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/strategy.rb:22:in `call'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/strategy.rb:54:in `call!'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/strategy.rb:22:in `call'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/strategy.rb:54:in `call!'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/strategy.rb:22:in `call'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/strategy.rb:54:in `call!'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/strategy.rb:22:in `call'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/strategy.rb:54:in `call!'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/strategy.rb:22:in `call'
  /home/ako/www/ako_pre/shared/bundle/ruby/1.8/gems/oa-core-0.2.0/lib/omniauth/builder.rb:30:in `call'
  devise (1.0.9) lib/devise/rails/warden_compat.rb:43:in `call'
  /home/ako/www/ako_pre/current/public/dispatch.fcgi:14

Rendering template within layouts/header
Rendering errors/404 (404)

I don't understand what happen (and what it should happen).
Last but not least it works fine in my development environment with production initializer.

I wonder if my production server could be responsible (Apache + FCGI) ?!

  map.connect '/auth/failure', :controller => :authentications, :action => :failure
  map.connect '/auth/:provider/callback', :controller => :authentications, :action => :create
ActionController::Dispatcher.middleware.use OmniAuth::Builder do
  provider :google_apps, OpenID::Store::Filesystem.new('/tmp'), :domain => 'gmail.com'
  provider :open_id, OpenID::Store::Filesystem.new('/tmp'), :name => 'yahoo', :identifier => 'https://yahoo.com'
  provider :open_id, OpenID::Store::Filesystem.new('/tmp'), :name => 'orange', :identifier => 'http://openid.orange.fr'
  provider :open_id, OpenID::Store::Filesystem.new('/tmp')
......
......
end
@mbleigh
Copy link
Contributor

mbleigh commented Apr 5, 2011

Try this in your routes:

map.connect '/auth/:provider', :controller => :authentications, :action => :blank

And in your controller:

def blank; render :text => "Not Found.", :status => 404 end

Does that fix it?

@elmatou
Copy link
Author

elmatou commented Apr 6, 2011

Hi Michael, thx for your answer,
But I had already tried this workaround (and tried again.) but I still get this 404 error.
Can you tell me what is the trick which trigger omniauth process ? Maybe I will find what is the issue with my app (and/or server).

Maybe it would be a good idea to have another way to trigger the process (eg in a controller action).

thx again.

@mbleigh
Copy link
Contributor

mbleigh commented Apr 6, 2011

OmniAuth is just a middleware, so if your middleware stack is working correctly it should work. That being said, I've never actually tried OmniAuth with Rails 2.3.x, so it may have some issues I'm unaware of.

@elmatou
Copy link
Author

elmatou commented Apr 7, 2011

Thanks for your response Michael,
I didn't get what I'm missing,
did the order of middleware elements matter ? Even if my stack look the same in both environments...
Rails.logger.debug ActionController::Dispatcher.middleware.inspect
gimme at runtime:

[Rack::Lock,
 ActionController::Failsafe,
 Devise::CookieSanitizer,
 ActionController::Session::CookieStore,
 #,
 Rails::Rack::Metal, ActionController::ParamsParser,
 Rack::MethodOverride,
 Rack::Head, ActionController::StringCoercion,
 OmniAuth::Builder,
 Warden::Manager,
 ActiveRecord::ConnectionAdapters::ConnectionManagement,
 ActiveRecord::QueryCache]

How can I test my Middleware stack ?
Do you think there could be a way to trigger the strategy inside a controller action, like does OmniAuth::Builder#provider ?
Or can the prefix_path change with my env (and no, my app is not in a sub-directory.) ?

@mbleigh
Copy link
Contributor

mbleigh commented Apr 26, 2011

I apologize for this, but for now I'm making the official line that OmniAuth doesn't support Rails 2.3.x. If you manage to get it working I'd love to post how on the wiki, but I don't have the resources to allocate to specifically solving problems for old versions of Rails. Thanks.

@mbleigh mbleigh closed this as completed Apr 26, 2011
@quake
Copy link
Contributor

quake commented Apr 26, 2011

OmniAuth supports rails 2.3.x, you need to add a blank action to routes.rb and controller:

  map.failure "/auth/failure", :controller => "third_party_auth", :action => "failure"
  map.callback "/auth/:provider", :controller => "third_party_auth", :action => "blank"
  map.callback "/auth/:provider/callback", :controller => "third_party_auth", :action => "create"
  def blank
    render :text => "Not Found", :status => 404
  end

@elmatou
Copy link
Author

elmatou commented Apr 26, 2011

@quake : As I mentionned it, this workaround don't fix my issue.
@mbleigh : migrating my app to an other environment fixed the issue, and omniauth works fine on the new eco-system.

I understand, that rails 2.3.x cannot be officially supported, but sometimes it works....

For the record :
Fail on : Shared Hosting (Custom distro : Linux 2.6.38.4-alwaysdata Debian 4.3.2-1.1) + Apache2 + FastCGI + Rails 2.3.11 + Omniauth 0.1.6 or 0.2.0

Work on : AWS-EC2 (Ubuntu : Linux 2.6.32-312-ec2 Ubuntu 4.4.3-4ubuntu5) + Apache2 + Passenger + Rails 2.3.11 + Omniauth 0.2

@k1w1
Copy link

k1w1 commented Mar 19, 2013

I had the same problem. The culprit is FastCGI. The real issue was that fastcgi doesn't create the PATH_INFO environment variable that Rack applications rely on. The fix is here: http://stackoverflow.com/a/15504313/583346.

@VDPoornima
Copy link

Hi,

I'm using rails 2.3.11 & ruby 1.8.7 versions. I couldn't run the server after the omni_auth.rb file included in the initializers folder. Im getting ""load_missing_constant': uninitialized constant ActionController::Dispatcher (NameError) " Please help me out.

@tmilewski
Copy link
Member

@PoornimaD Sorry, but, OmniAuth does not support Rails 2.3.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants