Skip to content

Commit 7d4c97e

Browse files
committed
Disable the Rails sandbox console
1 parent f0f2efd commit 7d4c97e

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ These config options are namespaced in `config.console1984`:
158158
| `incineration_queue` | The name of the queue for session incineration jobs. Default `console1984_incineration`. |
159159
| `base_record_class` | The host application base class that will be the parent of `console1984` records. By default it's `::ApplicationRecord`. |
160160

161+
`console1984` will disable the Rails sandbox console, becuase it's not able to record sessions while in sandbox mode. Set [`config.disable_sandbox = false`](https://guides.rubyonrails.org/configuring.html#config-disable-sandbox) if you still want to allow the sandbox.
162+
161163
### SSH Config
162164

163165
To automatically set the `CONSOLE_USER` env var for sessions, you'll need to configure SSH on the server to accept the environment variable.

lib/console1984/engine.rb

+7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ class Engine < ::Rails::Engine
88
config.console1984.protected_environments ||= %i[ production ]
99
config.console1984.protected_urls ||= []
1010

11+
# Console 1984 doesn't work with the sandboxed Rails console, becuase
12+
# it can't write its audit entries to the database. Unless you've explicitly
13+
# said so, we disable the sandboxed console to prevent this issue.
14+
initializer "console1984.disable_sandbox" do |app|
15+
app.config.disable_sandbox = true
16+
end
17+
1118
initializer "console1984.config" do
1219
config.console1984.each do |key, value|
1320
Console1984.config.send("#{key}=", value)

0 commit comments

Comments
 (0)