mercredi 27 mai 2015

Issue with Devise holding sessions on Elastic Beanstalk Unauthorized error. 401 Unauthorized

I am deploying an app onto Amazon ELastic Beanstalk with a load balanced configuration. It utilizes an RDS for the instances run on EC2. Overall I feel it's standard and I haven't had this issue with other apps.

Successful login:

Started GET "/users/sign_in" for x.x.x.x at some_time +0000
Processing by SessionsController#new as HTML
  Rendered devise/sessions/_form.html.haml (4.9ms)
  Rendered devise/shared/_links.haml (2.6ms)
  Rendered devise/sessions/new.html.haml within layouts/application (60.8ms)
  Rendered layouts/_logo_image.html.haml (2.7ms)
  Rendered layouts/_spinner.html.haml (1.8ms)
Completed 200 OK in 349.7ms (Views: 270.7ms | ActiveRecord: 0.0ms)
Started POST "/users/sign_in" for x.x.x.x at some_time23:43:07 +0000
Processing by SessionsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"spoijsoisjosijsoisjsoisjfaketoken", "user"=>{"login"=>"username1", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
  User Load (1.4ms)  SELECT `users`.* FROM `users` WHERE (`users`.`deleted_at` IS NULL) AND (`username` = 'username1' OR `email` = 'username1') LIMIT 1
  Administrator Load (1.6ms)  SELECT `users`.* FROM `users` WHERE `users`.`type` IN ('Administrator') AND (`users`.`deleted_at` IS NULL) AND (lower(username) = 'username1' OR lower(email) = 'username1') LIMIT 1
   (1.1ms)  BEGIN
   (1.2ms)  UPDATE `users` SET `last_sign_in_at` = 'some_time23:41:47', `current_sign_in_at` = 'some_time23:43:07', `sign_in_count` = 3690, `updated_at` = 'some_time23:43:07' WHERE `users`.`type` IN ('Administrator') AND `users`.`id` = 1
[paperclip] Saving attachments.
   (15.7ms)  COMMIT
   (1.7ms)  SELECT COUNT(*) FROM `topics` WHERE `topics`.`recipient_id` = 1 AND `topics`.`hidden_by_recipient` = 0 AND `topics`.`type` IN ('PrivateTopic') AND `topics`.`read` IS NULL
Redirected to http://ift.tt/1exnCrg
Completed 302 Found in 394.3ms (ActiveRecord: 29.9ms)
Started GET "/admin/users" for x.x.x.x at some_time23:43:12 +0000
Processing by Admin::UsersController#index as HTML
  Administrator Load (1.5ms)  SELECT `users`.* FROM `users` WHERE `users`.`type` IN ('Administrator') AND `users`.`id` = 1 AND (`users`.`deleted_at` IS NULL) LIMIT 1
   (1.6ms)  SELECT COUNT(*) FROM `users` WHERE (`users`.`deleted_at` IS NULL)
  User Load (3.0ms)  SELECT `users`.* FROM `users` WHERE (`users`.`deleted_at` IS NULL) ORDER BY created_at DESC LIMIT 25 OFFSET 0
  Rendered admin/users/_users.html.haml (371.6ms)
  Rendered admin/users/index.html.haml within layouts/application (435.9ms)
  Rendered layouts/_logo_image.html.haml (1.5ms)
  Rendered layouts/_spinner.html.haml (0.2ms)
   (2.0ms)  SELECT COUNT(*) FROM `topics` WHERE `topics`.`recipient_id` = 1 AND `topics`.`hidden_by_recipient` = 0 AND `topics`.`type` IN ('PrivateTopic') AND `topics`.`read` IS NULL
  Rendered shared/_public_profile.haml (7.7ms)
  Rendered shared/_admin_links.html.haml (6.1ms)
Completed 200 OK in 487.9ms (Views: 454.6ms | ActiveRecord: 16.1ms)

Unsuccessful login:

Started POST "/users/sign_in" for x.x.x.x at some_time 23:49:55 +0000
Processing by SessionsController#create as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"ssdsdsdsdssonsodnusdunsdfaketoken=", "user"=>{"login"=>"username1", "password"=>"[FILTERED]", "remember_me"=>"0"}, "commit"=>"Sign in"}
WARNING: Can't verify CSRF token authenticity
  User Load (1.3ms)  SELECT `users`.* FROM `users` WHERE (`users`.`deleted_at` IS NULL) AND (`username` = 'username1' OR `email` = 'username1') LIMIT 1
  Administrator Load (1.7ms)  SELECT `users`.* FROM `users` WHERE `users`.`type` IN ('Administrator') AND (`users`.`deleted_at` IS NULL) AND (lower(username) = 'username1' OR lower(email) = 'username1') LIMIT 1
   (1.2ms)  BEGIN
   (1.3ms)  UPDATE `users` SET `last_sign_in_at` = 'some_time 23:43:07', `current_sign_in_at` = 'some_time 23:49:56', `sign_in_count` = 3691, `updated_at` = 'some_time 23:49:56' WHERE `users`.`type` IN ('Administrator') AND `users`.`id` = 1
[paperclip] Saving attachments.
   (47.4ms)  COMMIT
   (1.8ms)  SELECT COUNT(*) FROM `topics` WHERE `topics`.`recipient_id` = 1 AND `topics`.`hidden_by_recipient` = 0 AND `topics`.`type` IN ('PrivateTopic') AND `topics`.`read` IS NULL
Redirected to http://ift.tt/1exnCrg
Completed 302 Found in 432.1ms (ActiveRecord: 64.3ms)
Started GET "/admin/users" for x.x.x.x at some_time 23:49:56 +0000
Processing by Admin::UsersController#index as HTML
Completed 401 Unauthorized in 2.4ms
Started GET "/users/sign_in" for x.x.x.x at some_time 23:49:57 +0000
Processing by SessionsController#new as HTML
  Rendered devise/sessions/_form.html.haml (2.8ms)
  Rendered devise/shared/_links.haml (0.4ms)
  Rendered devise/sessions/new.html.haml within layouts/application (5.6ms)
  Rendered layouts/_logo_image.html.haml (1.5ms)
  Rendered layouts/_spinner.html.haml (0.2ms)
Completed 200 OK in 21.3ms (Views: 18.5ms | ActiveRecord: 0.0ms)
Connecting to database specified by database.yml

I can only login using an obscure browser, Mantra. Firefox, Chrome and Safari all get the 401 unauthorized redirect.

Gem list:

aasm (3.0.16)
actionmailer (3.2.16)
actionpack (3.2.16)
active_model_serializers (0.8.1)
active_utils (1.0.5)
activemerchant (1.18.1)
activemodel (3.2.16)
activerecord (3.2.16)
activeresource (3.2.16)
activesupport (3.2.16)
acts_as_commentable (4.0.0)
akami (1.2.0)
arel (3.0.3)
attr_required (1.0.0)
aws-sdk (1.8.1.2)
axiom-types (0.0.5)
bcrypt (3.1.7)
bitly (0.8.1)
blankslate (3.1.2)
braintree (2.23.0)
bugsnag (1.6.4)
builder (3.0.4)
bundler (1.9.6)
cancan (1.6.7)
chronic (0.9.1)
cocaine (0.4.2)
coercible (1.0.0)
countries (0.8.4)
country-select (1.1.1)
crack (0.4.1)
createsend (1.1.1)
curb (0.8.6)
currencies (0.4.2)
daemons (1.1.9)
dante (0.2.0)
delayed_job (4.0.0)
delayed_job_active_record (4.0.0)
descendants_tracker (0.0.3)
devise (3.2.4)
devise_invitable (1.3.5)
diff-lcs (1.2.4)
dotenv (0.9.0)
dotenv-rails (0.9.0)
email_validator (1.3.0)
ensure-encoding (0.1)
equalizer (0.0.9)
erubis (2.7.0)
eventmachine (1.0.3)
execjs (1.4.0)
ey_config (0.0.6)
faraday (0.8.7)
gyoku (1.0.0)
haml (4.0.3)
haml-rails (0.4)
hashie (1.2.0)
hike (1.2.3)
hpricot (0.8.6)
httparty (0.11.0)
httpauth (0.2.0)
httpi (2.0.2)
i18n (0.6.9)
ice_nine (0.11.0)
jimson-temp (0.9.5)
journey (1.0.4)
jquery-rails (2.1.4)
jquery-ui-rails (2.0.2)
json (1.8.1)
jwt (0.1.8)
mail (2.5.4)
meta_search (1.1.3)
mime-types (1.25.1)
mini_magick (3.4)
mini_portile (0.5.2)
minitest (4.7.5)
minitest-rails (0.9.2)
money (5.1.1)
multi_json (1.10.1)
multi_xml (0.5.4)
multipart-post (1.2.0)
mysql2 (0.3.15)
newrelic_rpm (3.5.7.59)
nokogiri (1.6.1)
nori (2.1.0)
oauth (0.4.7)
oauth2 (0.8.1)
omniauth (1.1.4)
omniauth-facebook (1.4.1)
omniauth-linkedin (0.1.0)
omniauth-oauth (1.0.1)
omniauth-oauth2 (1.1.1)
omniauth-twitter (1.0.0)
orm_adapter (0.5.0)
paperclip (3.3.1)
paypal-express (0.5.5)
paypal-sdk-adaptivepayments (1.110.0)
paypal-sdk-core (0.2.9)
pdfkit (0.5.4)
polyamorous (0.5.0)
polyglot (0.3.5)
postmark (1.0.1)
postmark-rails (0.5.2)
psych (1.3.4)
quiet_assets (1.0.2)
rack (1.4.5)
rack-cache (1.2)
rack-ssl (1.3.4)
rack-test (0.6.2)
rails (3.2.16)
rails3_acts_as_paranoid (0.2.5)
railties (3.2.16)
rake (10.3.2)
rdoc (3.12.2)
responders (0.9.3)
rest-client (1.6.7)
restclient_with_cert (0.0.8)
rspec-core (2.13.1)
rspec-expectations (2.13.0)
rspec-mocks (2.13.1)
rspec-rails (2.13.2)
safe_yaml (0.9.5)
sampler (0.0.3)
sanitize (2.0.4)
sass (3.2.9)
sass-rails (3.2.5)
savon (2.2.0)
settingslogic (2.0.9)
simple_form (2.1.1)
simple_oauth (0.2.0)
sitemap_generator (4.1.0)
sprockets (2.2.2)
stripe (1.10.1)
stripe-ruby-mock (1.10.1.5)
strong_parameters (0.2.3)
subexec (0.2.3)
thin (1.5.1)
thor (0.19.1)
thread_safe (0.3.4)
tilt (1.4.1)
treetop (1.4.15)
twitter (4.8.1)
tzinfo (0.3.39)
uglifier (2.1.1)
uuidtools (2.1.4)
validation_reflection (1.0.0)
virtus (1.0.1)
warden (1.2.3)
wasabi (3.1.0)
whenever (0.8.2)
will_paginate (3.0.4)
xml-simple (1.1.3)

ELB is using a self-signed ssl cert in a staging environment with a load balancer enables with sticky sessions of 600 seconds long. During this testing though there is only one instance in use due to no load. There are no JS errors and the account is valid. The fact that it is only successfully logging in in Mantra is extremely unusual. Any and all help is appreciated.




Aucun commentaire:

Enregistrer un commentaire