Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [1.2.1] - 2026-03-17

### Added

- Support for callable values (Proc/Lambda) in `username` and `password` configuration, enabling use with `Rails.application.credentials` and other deferred sources ([#31](https://github.com/vishaltps/solid_queue_monitor/issues/31))
- Initializer template now shows ENV variable and Lambda examples for credentials

## [1.2.0] - 2026-03-07

### Changed
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
solid_queue_monitor (1.2.0)
solid_queue_monitor (1.2.1)
rails (>= 7.0)
solid_queue (>= 0.1.0)

Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,11 @@ SolidQueueMonitor.setup do |config|
config.authentication_enabled = false

# Set the username for HTTP Basic Authentication (only used if authentication is enabled)
# Supports static values, ENV variables, or callables (Proc/Lambda)
config.username = 'admin'

# Set the password for HTTP Basic Authentication (only used if authentication is enabled)
# Supports static values, ENV variables, or callables (Proc/Lambda)
config.password = 'password'

# Number of jobs to display per page
Expand Down Expand Up @@ -141,7 +143,21 @@ By default, Solid Queue Monitor does not require authentication to access the da
For production environments, it's strongly recommended to enable authentication:

1. **Enable authentication**: Set `config.authentication_enabled = true` in the initializer
2. **Configure secure credentials**: Set `username` and `password` to strong values in the initializer
2. **Configure secure credentials** using any of these approaches:

```ruby
# Static values
config.username = 'admin'
config.password = 'secure_password'

# Environment variables
config.username = ENV['SOLID_QUEUE_MONITOR_USERNAME']
config.password = ENV['SOLID_QUEUE_MONITOR_PASSWORD']

# Rails credentials (use a lambda for deferred evaluation)
config.username = -> { Rails.application.credentials.dig(:solid_queue_monitor, :username) }
config.password = -> { Rails.application.credentials.dig(:solid_queue_monitor, :password) }
```

## Usage

Expand Down
4 changes: 4 additions & 0 deletions lib/generators/solid_queue_monitor/templates/initializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@

# Set the username for HTTP Basic Authentication (only used if authentication is enabled)
# config.username = 'admin'
# config.username = ENV['SOLID_QUEUE_MONITOR_USERNAME']
# config.username = -> { Rails.application.credentials.dig(:solid_queue_monitor, :username) }

# Set the password for HTTP Basic Authentication (only used if authentication is enabled)
# config.password = 'password'
# config.password = ENV['SOLID_QUEUE_MONITOR_PASSWORD']
# config.password = -> { Rails.application.credentials.dig(:solid_queue_monitor, :password) }

# Number of jobs to display per page
# config.jobs_per_page = 25
Expand Down
17 changes: 16 additions & 1 deletion lib/solid_queue_monitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,23 @@
module SolidQueueMonitor
class Error < StandardError; end
class << self
attr_accessor :username, :password, :jobs_per_page, :authentication_enabled,
attr_writer :username, :password
attr_accessor :jobs_per_page, :authentication_enabled,
:auto_refresh_enabled, :auto_refresh_interval, :show_chart

def username
resolve_value(@username)
end

def password
resolve_value(@password)
end

private

def resolve_value(value)
value.respond_to?(:call) ? value.call : value
end
end

@username = 'admin'
Expand Down
2 changes: 1 addition & 1 deletion lib/solid_queue_monitor/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module SolidQueueMonitor
VERSION = '1.2.0'
VERSION = '1.2.1'
end
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,28 @@
expect(described_class.authenticate('wrong', 'wrong')).to be false
end
end

context 'when credentials are configured with callables' do
before do
SolidQueueMonitor.authentication_enabled = true
SolidQueueMonitor.username = -> { 'lambda_user' }
SolidQueueMonitor.password = -> { 'lambda_pass' }
end

after do
SolidQueueMonitor.authentication_enabled = false
SolidQueueMonitor.username = 'admin'
SolidQueueMonitor.password = 'password'
end

it 'resolves callable values for authentication' do
expect(described_class.authenticate('lambda_user', 'lambda_pass')).to be true
end

it 'rejects incorrect credentials with callable values' do
expect(described_class.authenticate('wrong', 'wrong')).to be false
end
end
end

describe '.authentication_required?' do
Expand Down
Loading