简体   繁体   English

如何使用devise的“ warden”对与使用devise的rails应用程序位于同一堆栈中的机架应用程序进行身份验证?

[英]How can I use devise's “warden” to authenticate a rack app in the same stack as the rails app that uses devise?

By the way, I'm using rails 3. 顺便说一句,我正在使用rails 3。

How can I use devise's "warden" to authenticate a rack app in the same stack as the rails app that uses devise ? 如何使用devise的“ warden”对与使用devise的rails应用程序位于同一堆栈中的机架应用程序进行身份验证?

My problem is that when I call this: 我的问题是当我打电话给我时:

request.env['warden'] # nil :(

from the other application on the rack stack I get nil ! 从机架堆栈上的其他应用程序我得到零!

I integrated dav4rack (webdav) in my rails app via config.ru. 我通过config.ru将dav4rack(webdav)集成到了我的rails应用程序中。 I use devise for authentication in my rails app. 我在我的Rails应用程序中使用devise进行身份验证。

When I try to access the "warden" from my custom dav4rack Resource, request.env['warden'] I get nil . 当我尝试从自定义的dav4rack资源访问“ warden”时, request.env ['warden']变为nil How can I use warden to authenticate in my dav4rack resource? 如何使用warden在dav4rack资源中进行身份验证?

Example of config.ru I use: 我使用的config.ru示例:

http://pastie.org/1240732 http://pastie.org/1240732

In your config.ru, Your stack doesn't use warden. 在您的config.ru中,您的堆栈不使用warden。

If you check a request to your '/' path, you use immediatly your Rack Application in your config.ru. 如果您检查对“ /”路径的请求,则可以立即在config.ru中使用机架应用程序。 The warden middlkeware is add on Rails application. 管理员middlkeware是在Rails应用程序上添加的。 So like your rack application call any other rack middleware you can't to have the warden information 因此,就像您的机架应用程序调用任何其他机架中间件一样,您将无法获得监护人信息

You need define your Rack application after the middleware warden. 您需要在中间件管理员之后定义Rack应用程序。 Because without Warden Middleware, there are no warden capability available. 因为没有Warden Middleware,就没有可用的Warden功能。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM