Password protection for blogs - #1081
Draft
lylo wants to merge 1 commit into
Draft
Conversation
Blog owners can set a password that gates the entire blog. Visitors are redirected to a themed unlock page and, on the correct password, an encrypted per-host cookie storing the blog's password_digest is set so the unlock survives changes to the session cookie and auto-invalidates when the password changes or is removed. Protected blogs skip Cloudflare edge caching so locked content is never served publicly.
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.
What
Adds whole-blog password protection. A blog owner can set a password in settings; visitors must enter it before they can read any posts or pages. Useful for private family journals or travelogues.
Distinct from the existing
hiddenflag on posts, which only unlists a post (the URL still serves to anyone). This is a real access gate.How
password_digestcolumn onblogs;Bloguseshas_secure_password(no length validation, so a visitor password need not meet the 12-char account rule).Blogs::BaseController#require_blog_passwordredirects protected blogs to a themed/unlockpage (rendered in the blog's own theme).password_digest. Because the cookie is the digest, changing or removing the password auto-invalidates every existing unlock. No session dependency, so it works even though blog pages skip the session cookie for edge caching.Notes / trade-offs
Tests
Model (
password_protected?, blank-is-noop, nil-clears), unlock controller (gating, correct/wrong password, cookie invalidation on password change, local-only redirect), and settings set/remove. Full blogs controller suite green.