OmniAuth工作得很好,但我注意到在 Rails v2.3.6 应用程序中使用它时,它会将请求传递到下一个 Rack 中间件,即使它最终自己处理请求并使用重定向响应。
代码摘录:(来自Github)
if current_path == request_path && OmniAuth.config.allow....
status, headers, body = *call_app!
@response = Rack::Response.new(body, status, headers)
request_phase
elsif current_path == callback_path
callback_phase
else
...
end
我的应用程序在通过/auth/provider
请求后会引发异常并返回 404。用户看不到这一点,但ExceptionNotifier
日志会看到。为了解决这个问题,我创建了另一个中间件,它只响应[200,{},[]]
所有路径,如/auth/provider_name
.
为什么 OmniAuth 将请求向下传递到中间件堆栈?