-
-
Notifications
You must be signed in to change notification settings - Fork 300
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
extracting status does fail with devise when authentication fails #67
Comments
I'm also seeing this issue on device |
I ran into this issue too and dug a bit deeper. It happens because devise sets the status here: https://github.com/plataformatec/devise/blob/master/lib/devise/controllers/helpers.rb#L77 which is usually called by rails here: However, lograge uses its own LogSubscriber to process the notifications from rails: https://github.com/roidrage/lograge/blob/master/lib/lograge/log_subscriber.rb#L8 The easy fix would be to call |
I ran into this same problem in our production app today and in order to help confirm the source I made a small rails app. I should have looked here first as it seems the culprit has already been identified! In case it's helpful I'll still drop the link here: https://github.com/rylwin/lograge-devise-test. |
I've managed to log a 401 overriding |
Just encountered this problem, too. Since the issue was closed a few days ago, does this mean that it has been fixed in upstream? |
Sadly not it seems. I'll reopen this and take a look today. |
Just encountered this too.
|
We have been having this issue as well. http://stackoverflow.com/questions/42142503/rails-server-returning-http-status-0 In our case, its because CSRF fails. However, we do use devise, but from a few requests I have sampled, its not caused by a devise 401. In all our cases, its because of the |
I am having this issue since switching to Lograge 3 months ago and like @bradseefeld it doesn't appear to be just Devise 401s. Using Lograge 0.4.1 with Rails 4.2.8 and Devise 4.2.1. I'm surprised this has been an issue since March 2014. |
The devise issue is caused by the problem described here: heartcombo/devise#4375. Despite the apparent failure by lograge to accommodate this I'm reluctant to handle the special case caused by devise. @brucew If you're experiencing issues outside of devise - post a reproduction for me to investigate. |
there is a PR in devise might fix this heartcombo/devise#4375 |
Any updates about this ? Should we just wait for the PR to be merged ? |
It's merged! |
😍 |
the PR was reverted lol |
Can confirm this is still an issue with the latest version of Devise ( I don't understand what this means:
|
I spent some time investigating this. This issue uncovered a number of issues:
activesupport-6.0.2/lib/active_support/notifications/instrumenter.rb:25:in `instrument'
activesupport-6.0.2/lib/active_support/notifications.rb:180:in `instrument'
actionpack-6.0.2/lib/action_controller/metal/instrumentation.rb:32:in `process_action' <--- This is where append_info_to_payload is called
actionpack-6.0.2/lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord-6.0.2/lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack-6.0.2/lib/abstract_controller/base.rb:136:in `process'
actionview-6.0.2/lib/action_view/rendering.rb:39:in `process'
actionpack-6.0.2/lib/action_controller/metal.rb:191:in `dispatch'
actionpack-6.0.2/lib/action_controller/metal.rb:252:in `dispatch'
actionpack-6.0.2/lib/action_dispatch/routing/route_set.rb:51:in `dispatch'
actionpack-6.0.2/lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack-6.0.2/lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack-6.0.2/lib/action_dispatch/journey/router.rb:32:in `each'
actionpack-6.0.2/lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack-6.0.2/lib/action_dispatch/routing/route_set.rb:837:in `call'
$ git diff
diff --git a/lib/devise/failure_app.rb b/lib/devise/failure_app.rb
index 7f80733c..3dc6b81f 100644
--- a/lib/devise/failure_app.rb
+++ b/lib/devise/failure_app.rb
@@ -15,6 +15,7 @@ module Devise
include Rails.application.routes.mounted_helpers
include Devise::Controllers::StoreLocation
+ include ActionController::Instrumentation
delegate :flash, to: :request However, this generates two log entries: one for {
"method": "POST",
"path": "/users/sign_in",
"format": "html",
"controller": "SessionsController",
"action": "create",
"status": 0,
"duration": 694.72,
"view": 0,
"db": 13.75,
"time": "2020-03-20T08:42:35.185Z",
"params": [
{
"key": "utf8",
"value": "✓"
},
{
"key": "authenticity_token",
"value": "[FILTERED]"
},
{
"key": "user",
"value": {
"login": "root",
"password": "[FILTERED]",
"remember_me": "0"
}
}
]
} {
"method": "POST",
"path": "/unauthenticated",
"format": "html",
"controller": "Gitlab::DeviseFailure",
"action": "respond",
"status": 404,
"duration": 2.19,
"view": 0,
"time": "2020-03-20T08:42:35.191Z",
"params": [
{
"key": "utf8",
"value": "✓"
},
{
"key": "authenticity_token",
"value": "[FILTERED]"
},
{
"key": "user",
"value": {
"login": "root",
"password": "[FILTERED]",
"remember_me": "0"
}
}
],
"exception.class": "ActiveRecord::RecordNotFound",
"exception.message": "ActiveRecord::RecordNotFound",
"exception.backtrace": [
"lib/gitlab/devise_failure.rb:18:in `respond'"
]
} Ideally, we'd combine these two entries into one, but I'm not sure whether that's easy right now. This may be a limitation of the way all this instrumentation works. I think the request is going from Rails -> Rack -> Warden -> Warden failure app. As far as the Rails controller goes, it finishes processing the request with a |
@stanhu I'm seeing these status code 0 log entries with Rails |
We also see status code 0 instead of 401, |
Status code 0 instead of 401 here as well, lograge |
I came across this issue today. Does anyone have a solution for it? |
This bug was fixed and the issue was closed. Then the fix was reverted since it was deemed to have too broad an effect. There is now a new bug that tracks the issue: |
It looks like there is an actual fix: #360. But it has not been merged or otherwise acknowledged. |
@benlovell I was wondering if there's any chance of reviving this? Or making it clear that the place to fix this is not Lograge, so I can ping the Devise folks? Without this, there are two strange behaviours:
Related:
Thanks! |
(I'm using rails 4.0.3, devise 3.2.3 and lograge 0.3.0.)
I'm not sure if this is really devise devise specific. When I make a request that fails authentication it returns a
401 Unauthorized
. lograge does log this withstatus=0
though. When I look atpayload
in https://github.com/roidrage/lograge/blob/master/lib/lograge/log_subscriber.rb#L56-L65, I getwhich is obviously the reason why
status=0
gets logged.With lograge disabled I get this log entry by rails:
I'm wondering if I am overlooking something here and if this can be somehow fixed. Anyone else seeing this issue?
The text was updated successfully, but these errors were encountered: