slash_console 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: ce5c167ad7075f34ff8836dc4542fc2a94c21d3c68e2097d355efa04be522b36
4
+ data.tar.gz: 46dcff4326683797e0b8a5b988cf79de48a3c23f74acd337588f52fca9e99cc4
5
+ SHA512:
6
+ metadata.gz: 12eaf5f35101ebd8c2f5e8aa0090fd7d45add33cae544d5f94801c22236d078a70f860a8512b41e65df17c32a80326129fa570b4d4b19746264ede8a7cc332b8
7
+ data.tar.gz: d63d18e2a67194c9bea7af62dfc4ca2b8d7c2ca61120c1955d35ac80f931821ceb7d159b111f2e8b332d8f3ada8a5ba44359903443a957275fd70987ff953620
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2025 FIRSTDRAFT, LLC
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # SlashConsole
2
+
3
+ A Rails engine that provides a web-based console interface at `/rails/console`, allowing easy access to a Rails console in both development and production environments.
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem "slash_console"
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ ```bash
16
+ bundle install
17
+ ```
18
+
19
+ That's it! Navigate to `/rails/console` in your browser.
20
+
21
+ ## Usage
22
+
23
+ ### Development
24
+
25
+ In development, no authentication is required. Simply visit:
26
+
27
+ ```
28
+ http://localhost:3000/rails/console
29
+ ```
30
+
31
+ ### Production
32
+
33
+ For production use, authentication is **required**. Set these environment variables:
34
+
35
+ ```bash
36
+ ADMIN_USERNAME="choose_your_own_username"
37
+ ADMIN_PASSWORD="choose_your_own_strong_password"
38
+ ```
39
+
40
+ Without these environment variables, you'll see an error message explaining what needs to be configured.
41
+
42
+ ⚠️ **Security Warning**: This gem provides direct access to your Rails console. In production:
43
+
44
+ - Only use for applications where the security trade-offs are acceptable. Basically, only for toy apps; never where real user data is at risk. For serious apps, SSH into the server and run `rails console` at the command-line.
45
+ - Make up a strong, unique `ADMIN_PASSWORD` for each app.
46
+
47
+ ## How It Works
48
+
49
+ SlashConsole is a lightweight wrapper around the excellent `web-console` gem. It:
50
+
51
+ 1. Provides a dedicated route for console access (instead of only on error pages).
52
+ 2. Renders a full-page console interface.
53
+ 3. Uses basic authentication when in production.
54
+
55
+ ## Development
56
+
57
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests.
58
+
59
+ To install this gem onto your local machine, run `bundle exec rake install`.
60
+
61
+ ### Running Tests
62
+
63
+ ```bash
64
+ bundle exec rake test
65
+ ```
66
+
67
+ ### Linting
68
+
69
+ This project uses [Standard](https://github.com/standardrb/standard) for Ruby style:
70
+
71
+ ```bash
72
+ bundle exec standardrb
73
+ ```
74
+
75
+ ## Contributing
76
+
77
+ Bug reports and pull requests are welcome on GitHub at https://github.com/firstdraft/slash_console.
78
+
79
+ ### Development Setup
80
+
81
+ 1. Fork the repository
82
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
83
+ 3. Make your changes
84
+ 4. Run tests and linting
85
+ 5. Commit your changes (`git commit -am 'Add some feature'`)
86
+ 6. Push to the branch (`git push origin my-new-feature`)
87
+ 7. Create a new Pull Request
88
+
89
+ ## License
90
+
91
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
92
+
93
+ ## Acknowledgments
94
+
95
+ This gem is built on top of the [web-console](https://github.com/rails/web-console) gem. Many thanks to the Rails team and web-console contributors for their excellent work.
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ require "bundler/setup"
2
+
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
6
+ load "rails/tasks/statistics.rake"
7
+
8
+ require "bundler/gem_tasks"
@@ -0,0 +1,15 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
10
+ * files in this directory. Styles in this file should be added after the last require_* statement.
11
+ * It is generally better to create a new file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
@@ -0,0 +1,4 @@
1
+ module SlashConsole
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,31 @@
1
+ module SlashConsole
2
+ class ConsoleController < ApplicationController
3
+ layout false
4
+
5
+ skip_before_action :verify_authenticity_token, if: -> { defined?(verify_authenticity_token) }
6
+
7
+ before_action :ensure_credentials_configured, if: -> { Rails.env.production? }
8
+ before_action :authenticate_user, if: -> { Rails.env.production? }
9
+
10
+ def index
11
+ console
12
+ render :index
13
+ end
14
+
15
+ private
16
+
17
+ def ensure_credentials_configured
18
+ if ENV["ADMIN_USERNAME"].blank? || ENV["ADMIN_PASSWORD"].blank?
19
+ render plain: 'Before you can access the console, you must set environment variables called "ADMIN_USERNAME" and "ADMIN_PASSWORD".',
20
+ status: :service_unavailable
21
+ end
22
+ end
23
+
24
+ def authenticate_user
25
+ authenticate_or_request_with_http_basic("Rails Console") do |username, password|
26
+ ActiveSupport::SecurityUtils.secure_compare(username, ENV["ADMIN_USERNAME"]) &&
27
+ ActiveSupport::SecurityUtils.secure_compare(password, ENV["ADMIN_PASSWORD"])
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Slash console</title>
5
+ <%= csrf_meta_tags %>
6
+ <%= csp_meta_tag %>
7
+
8
+ <%= yield :head %>
9
+
10
+ <%= stylesheet_link_tag "slash_console/application", media: "all" %>
11
+ </head>
12
+ <body>
13
+
14
+ <%= yield %>
15
+
16
+ </body>
17
+ </html>
@@ -0,0 +1,36 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Rails Console</title>
5
+ <meta name="viewport" content="width=device-width,initial-scale=1">
6
+ <style>
7
+ html, body {
8
+ height: 100%;
9
+ margin: 0;
10
+ padding: 0;
11
+ overflow: hidden;
12
+ }
13
+
14
+ /* Hide all content - console will fill the page */
15
+ body > * {
16
+ display: none !important;
17
+ }
18
+
19
+ /* Ensure the web-console div fills the entire viewport */
20
+ #console {
21
+ display: block !important;
22
+ position: fixed !important;
23
+ top: 0 !important;
24
+ left: 0 !important;
25
+ right: 0 !important;
26
+ bottom: 0 !important;
27
+ width: 100vw !important;
28
+ height: 100vh !important;
29
+ z-index: 999999 !important;
30
+ }
31
+ </style>
32
+ </head>
33
+ <body>
34
+ <!-- The console helper will inject the web-console here -->
35
+ </body>
36
+ </html>
data/config/routes.rb ADDED
@@ -0,0 +1,4 @@
1
+ SlashConsole::Engine.routes.draw do
2
+ get "console" => "console#index", :as => :console
3
+ root to: "console#index"
4
+ end
@@ -0,0 +1,11 @@
1
+ module SlashConsole
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace SlashConsole
4
+
5
+ initializer "slash_console.mount_engine" do |app|
6
+ app.routes.prepend do
7
+ mount SlashConsole::Engine => "/rails", :as => :slash_console_engine
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,3 @@
1
+ module SlashConsole
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,6 @@
1
+ require "slash_console/version"
2
+ require "slash_console/engine"
3
+ require "web-console"
4
+
5
+ module SlashConsole
6
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :slash_console do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,99 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: slash_console
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Raghu Betina
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: rails
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - ">="
17
+ - !ruby/object:Gem::Version
18
+ version: '7.0'
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ">="
24
+ - !ruby/object:Gem::Version
25
+ version: '7.0'
26
+ - !ruby/object:Gem::Dependency
27
+ name: web-console
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '4.0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - ">="
38
+ - !ruby/object:Gem::Version
39
+ version: '4.0'
40
+ - !ruby/object:Gem::Dependency
41
+ name: standard
42
+ requirement: !ruby/object:Gem::Requirement
43
+ requirements:
44
+ - - "~>"
45
+ - !ruby/object:Gem::Version
46
+ version: '1.0'
47
+ type: :development
48
+ prerelease: false
49
+ version_requirements: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - "~>"
52
+ - !ruby/object:Gem::Version
53
+ version: '1.0'
54
+ description: A Rails engine that provides a web-based console interface at /rails/console,
55
+ with production authentication support.
56
+ email:
57
+ - raghu@firstdraft.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - MIT-LICENSE
63
+ - README.md
64
+ - Rakefile
65
+ - app/assets/stylesheets/slash_console/application.css
66
+ - app/controllers/slash_console/application_controller.rb
67
+ - app/controllers/slash_console/console_controller.rb
68
+ - app/views/layouts/slash_console/application.html.erb
69
+ - app/views/slash_console/console/index.html.erb
70
+ - config/routes.rb
71
+ - lib/slash_console.rb
72
+ - lib/slash_console/engine.rb
73
+ - lib/slash_console/version.rb
74
+ - lib/tasks/slash_console_tasks.rake
75
+ homepage: https://github.com/firstdraft/slash_console
76
+ licenses:
77
+ - MIT
78
+ metadata:
79
+ homepage_uri: https://github.com/firstdraft/slash_console
80
+ source_code_uri: https://github.com/firstdraft/slash_console
81
+ changelog_uri: https://github.com/firstdraft/slash_console/blob/main/CHANGELOG.md
82
+ rdoc_options: []
83
+ require_paths:
84
+ - lib
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ requirements: []
96
+ rubygems_version: 3.7.1
97
+ specification_version: 4
98
+ summary: Mountable Rails console at /rails/console
99
+ test_files: []