Question

Je suis en train de travailler à ce que la meilleure façon de sécuriser mon environnement de mise en scène serait. Actuellement, je suis en cours d'exécution à la fois la mise en scène et la production sur le même serveur.

Les deux options que je peux penser serait à:

Utiliser l'authentification Digest rails

Je pourrais mettre quelque chose comme ça dans le application_controller.rb

# Password protection for staging environment
if RAILS_ENV == 'staging'
  before_filter :authenticate_for_staging
end

def authenticate_for_staging
  success = authenticate_or_request_with_http_digest("Staging") do |username|
    if username == "staging"
      "staging_password"
    end
  end
  unless success
    request_http_digest_authentication("Admin", "Authentication failed")
  end
end

a été arraché

Autres conseils

Si vous déployez des environnements multi-mise en scène et ainsi que votre environnement de production et de l'environnement de mise en scène, il vous suffit d'ajouter ces lignes à config / environnements / staging.rb

MyApp::Application.configure do
  # RESTRICTING ACCESS TO THE STAGE ENVIRONMENT
  config.middleware.insert_before(::Rack::Runtime, "::Rack::Auth::Basic", "Staging") do |u, p|
    u == 'tester' && p == 'secret'
  end

  ...

end

En faisant cela, vous n'avez pas besoin de configurer Apache.

J'utilise Ruby Rails 2 avec 4 et il fonctionne comme un charme!

J'irais avec l'authentification HTTP de base, je ne vois pas de problèmes inhérents avec elle.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top