如何在我的 Java 应用程序中访问 Rails 的会话 [英] How Can I Access Rails' Session In My Java App

查看:36
本文介绍了如何在我的 Java 应用程序中访问 Rails 的会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个域中有两个网络应用.一个是由 ruby​​ 编写的,另一个是由 java 编写的.我的 rails 应用程序正在使用 db session.所以我的数据库中有一个会话"表.我想要做的是在java中从这个表中读取会话信息.

I have two web apps in one domain. One is written by ruby another is by java. And my rails app is using db session. So there have a "sessions" table in my database. What I want to do is reading the session info from this table in java.

这是我的问题:Rails 的会话表已加密.所以我不能直接从JDBC读取它.

我不想写解密代码来转换它.因为在 java 和 rails 中拆分一个逻辑并不是一个好主意.所以我希望找到一种方法来取消rails中的加密会话数据行为.有谁知道如何在 rails 配置文件中写入它?

I don't want to write a decrypt code to convert it. Because it's not a good idea to split one logic both in java and rails. So I hope to find a way to cancel the encrypt session data behavior in rails. Does anyone know how to wirte it in rails config file?

谢谢!

推荐答案

Rails 代码中的加密方案不会改变,因此在 Java 中实现解密并不是一件可怕的事情.如果你想走这条路线,参考这个问题.然而,如果你真的想防止加密,它没有很好的文档记录,但是在 config/environment.rb 中它可能足以确保 config.action_controller.session 不包含键为 :secret 的条目.不过,请确保您通过其他方式保护您的数据库!

The encryption scheme isn't going to change in the Rails code, so it's not a horrible thing to implement the decryption in Java. If you want to take this route, refer to this question. However, if you really want to prevent encryption, it's not well documented, but in config/environment.rb it would probably suffice to make sure that the hash in config.action_controller.session does not contain an entry with the key :secret. Make sure you secure your database with other means though!

这篇关于如何在我的 Java 应用程序中访问 Rails 的会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆