feat: Add configurable HTTP Basic Authentication for the web UI - #148
Open
HassaanSiraj wants to merge 3 commits into
Open
feat: Add configurable HTTP Basic Authentication for the web UI#148HassaanSiraj wants to merge 3 commits into
HassaanSiraj wants to merge 3 commits into
Conversation
HassaanSiraj
force-pushed
the
feat/add-basic-auth
branch
2 times, most recently
from
February 23, 2026 22:41
d4735eb to
f51123c
Compare
stevenharman
reviewed
Apr 8, 2026
|
|
||
| module LetterOpenerWeb | ||
| class ApplicationController < ActionController::Base | ||
| before_action :enforce_basic_auth, if: -> { LetterOpenerWeb.config.enabled? } |
Collaborator
There was a problem hiding this comment.
A general #enabled? makes it seem like it's checking if LetterOpenerWeb itself is enabled or not. But that's not the case. I think we should be more explicit.
Suggested change
| before_action :enforce_basic_auth, if: -> { LetterOpenerWeb.config.enabled? } | |
| before_action :enforce_basic_auth, if: -> { LetterOpenerWeb.config.basic_auth_enabled? } |
Author
There was a problem hiding this comment.
I see your point, this makes the intent much clearer. I’ll go ahead and update it to reflect this.
- Inline before_action condition with a lambda instead of a separate private method - Add .to_s guard on credentials in secure_compare - Rename validate! to warn_if_basic_auth_misconfigured for clarity - Add enabled? alias for basic_auth_enabled? - Merge attr_accessor declarations into a single line - Fix long lines in controller specs
HassaanSiraj
force-pushed
the
feat/add-basic-auth
branch
from
April 8, 2026 23:59
f51123c to
0bf333e
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds opt-in HTTP Basic Authentication to protect the Letter Opener Web interface, primarily useful for staging and pre-production environments where the UI is accessible but should not be publicly open.
Users can enable it via the existing LetterOpenerWeb.configure block in a Rails initializer:
LetterOpenerWeb.configure do |config| config.authentication_enabled = true config.username = ENV['LETTER_OPENER_WEB_USERNAME'] config.password = ENV['LETTER_OPENER_WEB_PASSWORD'] endDetails
Test plan