-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Cascade of Issues with Omniauth(?) #18
Comments
Yikes!
|
Hey Lynn: Devise is 3.2.4 require 'sidekiq/web'
Gaia::Application.routes.draw do
namespace :admin do
mount Sidekiq::Web, at: '/queue'
end
constraints(id: Rails.application.config.uuid_regex) do
namespace :api, defaults: {format: :json} do
namespace :v1 do
mount_devise_token_auth_for 'User', at: '/auth'
resources :users, except: [:new, :edit], constraints: {id: /[a-z0-9-]+/} do
resources :galleries, except: [:new, :edit]
end
get :'search/:q', controller: :search, action: :search
end
end
end
root to: 'home#index'
end No conflicts that I can think of, this is a pretty new project that's bonehead basic right now, nothing really fancy going on. |
Ok I think I see the problem. Devise doesn't seem to handle namespaces very well. Try removing this line from within the namespace blocks: mount_devise_token_auth_for 'User', at: '/auth' And then provide the entire namespace explicitly like this: mount_devise_token_auth_for 'User', at: '/api/v1/auth' So that the complete file looks like this: require 'sidekiq/web'
Gaia::Application.routes.draw do
mount_devise_token_auth_for 'User', at: '/api/v1/auth'
namespace :admin do
mount Sidekiq::Web, at: '/queue'
end
constraints(id: Rails.application.config.uuid_regex) do
namespace :api, defaults: {format: :json} do
namespace :v1 do
resources :users, except: [:new, :edit], constraints: {id: /[a-z0-9-]+/} do
resources :galleries, except: [:new, :edit]
end
get :'search/:q', controller: :search, action: :search
end
end
end
root to: 'home#index'
end |
@PeteMichaud - if this works, let me know and I'll add a note in the README. |
I have a series of issues. I have a project that mounts all the routes inside the api, eg:
When I try to authenticate against google_oauth2, I hit this route: http://localhost:5000/api/v1/auth/google_oauth2?auth_origin_url=http://localhost:5000/#/
and it throws this:
NoMethodError
undefined method `valid_encoding?' for :json:Symbol
actionpack (4.1.0) lib/action_dispatch/routing/redirection.rb:24:in
'block in call' actionpack (4.1.0) lib/action_dispatch/routing/redirection.rb:22:in
each'actionpack (4.1.0) lib/action_dispatch/routing/redirection.rb:22:in
call' actionpack (4.1.0) lib/action_dispatch/routing/mapper.rb:45:in
call'actionpack (4.1.0) lib/action_dispatch/journey/router.rb:71:in
block in call' actionpack (4.1.0) lib/action_dispatch/journey/router.rb:59:in
each'actionpack (4.1.0) lib/action_dispatch/journey/router.rb:59:in
call' actionpack (4.1.0) lib/action_dispatch/routing/route_set.rb:676:in
call'omniauth (1.2.2) lib/omniauth/strategy.rb:186:in
call!' omniauth (1.2.2) lib/omniauth/strategy.rb:164:in
call'omniauth (1.2.2) lib/omniauth/strategy.rb:186:in
call!' omniauth (1.2.2) lib/omniauth/strategy.rb:164:in
call'omniauth (1.2.2) lib/omniauth/strategy.rb:186:in
call!' omniauth (1.2.2) lib/omniauth/strategy.rb:164:in
call'omniauth (1.2.2) lib/omniauth/builder.rb:59:in
call' rack-cors (0.2.9) lib/rack/cors.rb:54:in
call'warden (1.2.3) lib/warden/manager.rb:35:in
block in call' warden (1.2.3) lib/warden/manager.rb:34:in
catch'warden (1.2.3) lib/warden/manager.rb:34:in
call' rack (1.5.2) lib/rack/etag.rb:23:in
call'rack (1.5.2) lib/rack/conditionalget.rb:25:in
call' rack (1.5.2) lib/rack/head.rb:11:in
call'remotipart (1.2.1) lib/remotipart/middleware.rb:27:in
call' actionpack (4.1.0) lib/action_dispatch/middleware/params_parser.rb:27:in
call'actionpack (4.1.0) lib/action_dispatch/middleware/flash.rb:254:in
call' rack (1.5.2) lib/rack/session/abstract/id.rb:225:in
context'rack (1.5.2) lib/rack/session/abstract/id.rb:220:in
call' actionpack (4.1.0) lib/action_dispatch/middleware/cookies.rb:560:in
call'activerecord (4.1.0) lib/active_record/query_cache.rb:36:in
call' activerecord (4.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:621:in
call'activerecord (4.1.0) lib/active_record/migration.rb:380:in
call' actionpack (4.1.0) lib/action_dispatch/middleware/callbacks.rb:29:in
block in call'activesupport (4.1.0) lib/active_support/callbacks.rb:82:in
run_callbacks' actionpack (4.1.0) lib/action_dispatch/middleware/callbacks.rb:27:in
call'actionpack (4.1.0) lib/action_dispatch/middleware/reloader.rb:73:in
call' actionpack (4.1.0) lib/action_dispatch/middleware/remote_ip.rb:76:in
call'actionpack (4.1.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:in
call' actionpack (4.1.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in
call'railties (4.1.0) lib/rails/rack/logger.rb:38:in
call_app' railties (4.1.0) lib/rails/rack/logger.rb:20:in
block in call'activesupport (4.1.0) lib/active_support/tagged_logging.rb:68:in
block in tagged' activesupport (4.1.0) lib/active_support/tagged_logging.rb:26:in
tagged'activesupport (4.1.0) lib/active_support/tagged_logging.rb:68:in
tagged' railties (4.1.0) lib/rails/rack/logger.rb:20:in
call'quiet_assets (1.0.2) lib/quiet_assets.rb:18:in
call_with_quiet_assets' actionpack (4.1.0) lib/action_dispatch/middleware/request_id.rb:21:in
call'rack (1.5.2) lib/rack/methodoverride.rb:21:in
call' rack (1.5.2) lib/rack/runtime.rb:17:in
call'activesupport (4.1.0) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in
call' rack (1.5.2) lib/rack/lock.rb:17:in
call'actionpack (4.1.0) lib/action_dispatch/middleware/static.rb:64:in
call' rack (1.5.2) lib/rack/sendfile.rb:112:in
call'railties (4.1.0) lib/rails/engine.rb:514:in
call' railties (4.1.0) lib/rails/application.rb:144:in
call'unicorn (4.8.2) lib/unicorn/http_server.rb:572:in
process_client' unicorn (4.8.2) lib/unicorn/http_server.rb:666:in
worker_loop'unicorn (4.8.2) lib/unicorn/http_server.rb:521:in
spawn_missing_workers' unicorn (4.8.2) lib/unicorn/http_server.rb:140:in
start'unicorn (4.8.2) bin/unicorn_rails:209:in
<top (required)>' /Users/pete/.rvm/gems/ruby-2.1.1/bin/unicorn_rails:23:in
load'/Users/pete/.rvm/gems/ruby-2.1.1/bin/unicorn_rails:23:in
<top (required)>' ruby-debug-ide (0.4.22) lib/ruby-debug-ide.rb:86:in
debug_load'ruby-debug-ide (0.4.22) lib/ruby-debug-ide.rb:86:in
debug_program' ruby-debug-ide (0.4.22) bin/rdebug-ide:110:in
<top (required)>'-e:1:in
load' -e:1:in
:json is a symbol instead of a string. I have no idea why. So as an experiment I hacked the core file to first check whether the value responds to valid_encoding? -- if it doesn't, then it skips it. When I make that change things work better (obviously that is a short term hack, the real solution is to figure out why the symbol is being passed). But that brings us to the second problem.
If the above issues weren't happening, then it redirects successfully to the google login screen, where it shows all the google identities I have a cookie for. I select my main one that I know I'm logged into and it redirects me to:
http://localhost:5000/omniauth/failure?message=invalid_credentials&origin=http%3A%2F%2Flocalhost%3A5000%2F&strategy=google_oauth2
But when it tries that, rails throws a Routing Error.
/omniauth/failure
isn't the right route, it's supposed to be/api/v1/auth/failure
.So If I could fix the redirect so it hit the correct route, then I'd see an erroneous message about invalid credentials. I'm hoping you can help me untangle this!
The text was updated successfully, but these errors were encountered: