Skip to content

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

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.

2 participants