Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ability to password protect certain pages #636

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

murny
Copy link
Collaborator

@murny murny commented Aug 29, 2024

From #551 Natasha wanted the following functionality:

I'm not sure if this is in scope, but there has been some interest in having some areas of the UAL website (specifically staffhub) password protected so that only staff can access them.

We can do this by hooking into Comfy's public_auth method and adding some authentication logic for this.

The logic in this PR just makes any cms page path containing "secret" to be password protected. This could easily be changed or expanded upon.

But this will meet the basic requirements for Natasha's ask. This currently works with the current basic auth system we have in place, but could easily be updated to work with Devise as well.

protected_paths = ["secret"]

return unless protected_paths.any? { |protected_path| params["cms_path"].include?(protected_path) }
authenticate_or_request_with_http_basic do |username, password|
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If using devise we can just update this to something like redirect_to login_path unless current_user

@murny murny mentioned this pull request Aug 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant