rack

How to filter sensitive information when logging with Sinatra and Rack Logger

落花浮王杯 提交于 2020-07-30 05:53:22
问题 I maintain a Sinatra app that acts as a JSON API service. The API is consumed by another web app, as well as a mobile app. I'd like to have Rack::CommonLogger exclude sensitive information, like a password, from its logs. Rails has this setting enabled, but I have found no documentation how to do this in Sinatra. 回答1: You can try to intercept the call to write and filter out sensitive messages like so : logger = Logger.new("my_common.log") logger.instance_eval do def write(msg) self.send(:<<,

How to filter sensitive information when logging with Sinatra and Rack Logger

余生长醉 提交于 2020-07-30 05:52:20
问题 I maintain a Sinatra app that acts as a JSON API service. The API is consumed by another web app, as well as a mobile app. I'd like to have Rack::CommonLogger exclude sensitive information, like a password, from its logs. Rails has this setting enabled, but I have found no documentation how to do this in Sinatra. 回答1: You can try to intercept the call to write and filter out sensitive messages like so : logger = Logger.new("my_common.log") logger.instance_eval do def write(msg) self.send(:<<,

How do I set a cookie with a (ruby) rack middleware component?

自闭症网瘾萝莉.ら 提交于 2020-07-17 05:41:35
问题 I'm writing a rack middleware component for a rails app that will need to conditionally set cookies. I am currently trying to figure out to set cookies. From googling around it seems like this should work: class RackApp def initialize(app) @app = app end def call(env) @status, @headers, @response = @app.call(env) @response.set_cookie("foo", {:value => "bar", :path => "/", :expires => Time.now+24*60*60}) [@status, @headers, @response] end end which doesn't give errors, but doesn't set a cookie

Trace Error in Rack Middleware

人盡茶涼 提交于 2020-06-26 07:56:15
问题 I'm not 100% sure at this point, but I believe I'm getting an exception that is causing the status of a request to respond with a 401. I've eliminated all the code in the controller, and the issue still happens, and something seems to be catching the exception in order to return the 401 status, so there's no stack trace. I've created a custom middleware to try and debug, but I still haven't been able to get to the source of the issue. How can I isolate where the issue is happening? We are

Rename session cookies in Rails

眉间皱痕 提交于 2020-05-29 02:31:53
问题 since I'd like the session cookie to reflect the url and not the app name, I'd like to rename the cookies.. The current session cookie name is called _APPNAME_session is there a way to rename it to _somethingelse_session ? I see the name of it when I do curl -i <appurl> I see set_cookie = _APPNAME_session=.... 回答1: In config/initializers/session_store.rb, set/change the following line: For Rails < 5.0.0: <APPNAME>::Application.config.session_store :cookie_store, key: '_somethingelse_session'

Rename session cookies in Rails

余生长醉 提交于 2020-05-29 02:30:47
问题 since I'd like the session cookie to reflect the url and not the app name, I'd like to rename the cookies.. The current session cookie name is called _APPNAME_session is there a way to rename it to _somethingelse_session ? I see the name of it when I do curl -i <appurl> I see set_cookie = _APPNAME_session=.... 回答1: In config/initializers/session_store.rb, set/change the following line: For Rails < 5.0.0: <APPNAME>::Application.config.session_store :cookie_store, key: '_somethingelse_session'

Rename session cookies in Rails

自闭症网瘾萝莉.ら 提交于 2020-05-29 02:30:17
问题 since I'd like the session cookie to reflect the url and not the app name, I'd like to rename the cookies.. The current session cookie name is called _APPNAME_session is there a way to rename it to _somethingelse_session ? I see the name of it when I do curl -i <appurl> I see set_cookie = _APPNAME_session=.... 回答1: In config/initializers/session_store.rb, set/change the following line: For Rails < 5.0.0: <APPNAME>::Application.config.session_store :cookie_store, key: '_somethingelse_session'

ceph手动安装

瘦欲@ 提交于 2020-05-03 13:46:12
本文主要讲述在无外网条件下安装ceph存储集群的过程。具体的安装环境如下: [root@ceph001-node1 /]# lsb_release -a LSB Version: :core-4.1-amd64:core-4.1-noarch Distributor ID: CentOS Description: CentOS Linux release 7.1.1503 (Core) Release: 7.1.1503 Codename: Core [root@ceph001-node1 /]# uname -a Linux ceph001-node1 3.10.0-229.el7.x86_64 #1 SMP Fri Mar 6 11:36:42 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux 这里采用了3台虚拟机: 主机IP 部署组件 主机名 10.133.134.211 node1 ceph001-node1 10.133.134.212 node2 ceph001-node2 10.133.134.213 node3 ceph001-node3 1. 下载软件安装包 因为我们是在无外网环境下安装ceph,因此我们需要在另外一台能够联网的机器上下载到对应的软件安装包。 注意:这里我们的下载软件包的主机环境最好与实际的安装环境一致

014 Ceph管理和自定义CRUSHMAP

自闭症网瘾萝莉.ら 提交于 2020-04-27 18:33:49
一、概念 1.1 Ceph集群写操作流程 client首先访问ceph monitor获取cluster map的一个副本,知晓集群的状态和配置 数据被转化为一个或多个对象,每个对象都具有对象名称和存储池名称 以PG数为基数做hash,将对象映射到一个PG 根据计算出的PG,再通过CRUSH算法得到存放数据的一组OSD位置(副本个数),第一个是主,后面是从 客户端获得OSD ID,直接和这些OSD通信并存放数据 注: 以上所有操作都是在客户端完成 的,不会影响ceph集群服务端性能 1.2 Crush和对象放置策略 Ceph使用CRUSH算法(Controlled Replication Under Scalable Hashing 可扩展哈希下的受控复制)来计算哪些OSD存放哪些对象 对象分配到PG中,CRUSH决定这些PG使用哪些OSD来存储对象。理想情况下,CRUSH会将数据均匀的分布到存储中 当添加新OSD或者现有的OSD出现故障时,Ceph使用CRUSH在活跃的OSD上重平衡数据 CRUSH map是CRUSH算法的中央配置机制,可通过调整CRUSH map来优化数据存放位置 默认情况下,CRUSH将对象放置到不同主机上的OSD中。可以配置CRUSH map和CRUSH rules,使对象放置到不同房间或者不同机柜的主机上的OSD中

大数据系列之再识Hadoop文件系统HDFS

蹲街弑〆低调 提交于 2020-04-23 06:00:06
CDA数据分析 出品 在搭建伪分布集群或者搭建分布式集群过程中经常提到HDFS,HDFS到底是什么东东呢?今天我们就给小伙伴们详细介绍一下。 1、 HDFS简介 HDFS(Hadoop Distributed File System)是hadoop项目的核心子项目,是分布式计算中数据存储管理的基础。是基于流数据模式访问和处理超大文件的需求而开发的, 可以运行于廉价的商用服务器上。 它所具有的高容错、 高可靠性、 高可扩展性、 高获得性、 高吞吐率等特征为海量数据提供了不怕故障的存储, 为超大数据集(Large Data Set) 的应用处理带来了很多便利。 HDFS是开源的,存储着Hadoop应用将要处理的数据,类似于普通的Unix和linux文件系统,不同的是它是实现了google的GFS文件系统的思想,是适用于大规模分布式数据处理相关应用的、可扩展的分布式文件系统。 2、 HDFS与Hadoop之间的关系 Hadoop是一个以一种可靠、高效、可伸缩的方式进行处理的,能够对大量数据进行分布式处理的系统框架。 HDFS是hadoop兼容最好的标准级文件系统。 所以可以理解为hadoop是一个框架, HDFS 是Hadoop中的一个部件。 3、 为什么需要HDFS 小量的数据,单机的磁盘是能够很好地处理面对的数据,但当数据量巨大(PB)时,磁盘开始纠结处理我们需要的海量信息