-
Notifications
You must be signed in to change notification settings - Fork 36
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
Check for the case where the engine is not mounted #35
Check for the case where the engine is not mounted #35
Conversation
Good improvement! I'll add that it could be interesting that the gem triggers authentication only on the presence on the mounted route, wether or not the Indeed, if you 'forget' the environment variable from your staging conf your environment is open to the world. And you might even not notice it since your so used to be automatically logged in 😆 |
@nicolasrouanne That's an interesting idea. For example, you're probably going to set up most of your staging environment correctly (because you call I think your idea is more future-proof, and mount Lockup::Engine, at: '/lockup' if Rails.env.staging? I follow Heroku's recommendation to not create a separate staging environment, but I still use a mount Lockup::Engine, at: '/lockup' if ENV['STAGING'] You can also enforce this behavior in your own app. I've just updated my code in if ENV['STAGING']
unless ENV['LOCKUP_CODEWORD'].present?
raise "You must set the LOCKUP_CODEWORD env variable to password-protect the staging environment."
end
mount Lockup::Engine, at: '/lockup'
end Thanks a lot for the idea! I'm actually planning to migrate to a new platform soon, and it's very possible that I would have forgotten to set the |
I like this check and the refactor is nice. I’ll give it some testing as soon as I have a chance and get it merged into |
@nicolasrouanne @ndbroadbent As far as the discussion related to keeping things locked if a codeword isn’t set: I’m not saying my mind can’t be changed, but I’ve always really liked the simplicity of tying Lockup to the codeword variable (however you set it). I often still use Lockup in my I understand it could be easy to forget to set the variable if you move hosting environments, but how often does that happen? Remember that this gem is supposed to be about light security, rather than actual security—it's like a lock on a fence you could hop over. Personally, I would be more concerned about forgetting that the gem was set up in a production bundle and accidentally locking down a production site. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍👍
Also refactor the code a little bit to remove duplication.
Closes #33