rails-secrets icon indicating copy to clipboard operation
rails-secrets copied to clipboard

Does not work in Rails 3.2

Open Overload119 opened this issue 10 years ago • 3 comments

A secret is required to generate an integrity hash for cookie session data. Use config.secret_token = "some secret phrase of at least 30 characters"in config/initializers/secret_token.rb

Overload119 avatar Aug 05 '15 21:08 Overload119

      config.after_initialize do |app|
        if app.secrets.secret_key_base.blank?
          raise "Missing `secret_key_base` for '#{Rails.env}' environment, set this value in `config/secrets.yml`"
        else
          app.config.secret_key_base = app.secrets.secret_key_base
        end
      end

Is probably the issue. Rails expects secret_token right?

Overload119 avatar Aug 05 '15 21:08 Overload119

An alternative way to get this to work;

Don't remove the secret_token.rb as suggested in the README, instead just change it to this.

# Be sure to restart your server when you modify this file.

# Your secret key for verifying the integrity of signed cookies.
# If you change this key, all old signed cookies will become invalid!
# Make sure the secret is at least 30 characters and all random,
# no regular words or you'll be exposed to dictionary attacks.

# Set token based on intialize_secret function (defined in initializers/secret_generator.rb)
RailsApp::Application.config.secret_token = Rails.application.secrets.secret_key_base

Overload119 avatar Aug 05 '15 23:08 Overload119

Confirmed. Doesn't work with Rails 3.2 out of the box without doing something like this. This should probably go in the readme.

gregblass avatar Feb 03 '16 19:02 gregblass