使用 DataMapper 作为 Padrino 会话存储
我能够使 Rack::Session::DataMapper、Padrino 和 Omniauth 协同工作。主要目标是在主应用程序和管理部分拥有相同的会话和用户,并且拥有非常持久的会话。选项 set :sessions
已禁用,因此我修补了 /padrino-core-0.9.23/lib\padrino-core/application.rb:203
use Rack: :Flash if flash?
不需要会话?
。我还修补了 /padrino-admin-0.9.23/lib/padrino-admin/access_control.rb:15
以不启用会话。
这是我的应用程序代码:
/admin/app.rb:
set :session_id, 'superapp.pro'.to_sym
use Rack::Session::DataMapper
/app/app.rb:
set :session_id, 'superapp.pro'.to_sym
use Rack::Session::DataMapper
/lib/omniauth_init.rb:
use Rack::Session::DataMapper
问题是:是否有更好的方法来与 Omniauth 建立自定义机架会话存储的关系?我对使用 Rack::Session::DataMapper
三次感到不舒服。
I was able to make Rack::Session::DataMapper, Padrino and Omniauth work together. The main goal was to have the same sessions and users in the main app and in the admin section, and to have very long lasting sessions. Option set :sessions
was disabled, so I patched /padrino-core-0.9.23/lib\padrino-core/application.rb:203
use Rack::Flash if flash?
to not require sessions?
. Also I patched /padrino-admin-0.9.23/lib/padrino-admin/access_control.rb:15
to not enable sessions.
Here is my app code:
/admin/app.rb:
set :session_id, 'superapp.pro'.to_sym
use Rack::Session::DataMapper
/app/app.rb:
set :session_id, 'superapp.pro'.to_sym
use Rack::Session::DataMapper
/lib/omniauth_init.rb:
use Rack::Session::DataMapper
Question is: is there a nicer way to befriend custom rack session store with Omniauth? I'm not comfortable with using Rack::Session::DataMapper
three times.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
迟到的答案,但我相信如果你把:
在你的“config/boot.rb”中你会没事的,并且不需要重复。
Late answer, but I believe if you put:
in the your "config/boot.rb" you'll be fine, and won't need duplicates.