encrypted_cookie_store-instructure 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/encrypted_cookie_store-instructure.gemspec +1 -1
 - data/lib/encrypted_cookie_store.rb +11 -11
 - metadata +1 -1
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 27e3c5226ac9e726a47ab8da90ae4eb9acbc8b15
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 5cb56758aa39b4d5f721f217077ff5ee8116f836
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 2e0315240b2e955a55a3195bf3e695b08b760de2faab74c27f57f13e54d61f30dafc4a309aba0389946945694917268fa6c83541246fca8c7a44147a611fee50
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 82ade9b34862910f376f96c825f0f6eaac428a24519cec8b78c64231e83e1137f992d150d24827d85954d69f4869dd5e4fbf072fc8af5f97e1241795a4d26b7b
         
     | 
| 
         @@ -29,10 +29,10 @@ module ActionDispatch 
     | 
|
| 
       29 
29 
     | 
    
         
             
                    @secret = options.delete(:secret)
         
     | 
| 
       30 
30 
     | 
    
         
             
                    @secret = @secret.call if @secret.respond_to?(:call)
         
     | 
| 
       31 
31 
     | 
    
         
             
                    @secret.freeze
         
     | 
| 
       32 
     | 
    
         
            -
                    @encryption_key = unhex(@secret).freeze
         
     | 
| 
       33 
     | 
    
         
            -
                    ensure_encryption_key_secure
         
     | 
| 
       34 
32 
     | 
    
         | 
| 
       35 
33 
     | 
    
         
             
                    @data_cipher = OpenSSL::Cipher.new(EncryptedCookieStore.data_cipher_type)
         
     | 
| 
      
 34 
     | 
    
         
            +
                    @encryption_key = unhex(@secret[0...(@data_cipher.key_len * 2)]).freeze
         
     | 
| 
      
 35 
     | 
    
         
            +
                    ensure_encryption_key_secure
         
     | 
| 
       36 
36 
     | 
    
         
             
                    options[:refresh_interval] ||= 5.minutes
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
                    super(app, options)
         
     | 
| 
         @@ -195,20 +195,20 @@ module ActionDispatch 
     | 
|
| 
       195 
195 
     | 
    
         
             
                  # To prevent users from using an insecure encryption key like "Password" we make sure that the
         
     | 
| 
       196 
196 
     | 
    
         
             
                  # encryption key they've provided is at least 30 characters in length.
         
     | 
| 
       197 
197 
     | 
    
         
             
                  def ensure_encryption_key_secure
         
     | 
| 
       198 
     | 
    
         
            -
                    if @ 
     | 
| 
      
 198 
     | 
    
         
            +
                    if @secret.blank?
         
     | 
| 
       199 
199 
     | 
    
         
             
                      raise ArgumentError, "An encryption key is required for encrypting the " +
         
     | 
| 
       200 
200 
     | 
    
         
             
                          "cookie session data. Please set config.action_controller.session = { " +
         
     | 
| 
       201 
     | 
    
         
            -
                          "..., : 
     | 
| 
       202 
     | 
    
         
            -
                          " 
     | 
| 
      
 201 
     | 
    
         
            +
                          "..., :secret => \"some random hex string of at least " +
         
     | 
| 
      
 202 
     | 
    
         
            +
                          "#{@data_cipher.key_len} bytes\", ... } in config/environment.rb"
         
     | 
| 
       203 
203 
     | 
    
         
             
                    end
         
     | 
| 
       204 
204 
     | 
    
         | 
| 
       205 
     | 
    
         
            -
                    if @ 
     | 
| 
      
 205 
     | 
    
         
            +
                    if @secret.size < @data_cipher.key_len * 2
         
     | 
| 
       206 
206 
     | 
    
         
             
                      raise ArgumentError, "The EncryptedCookieStore encryption key must be a " +
         
     | 
| 
       207 
     | 
    
         
            -
                          "hexadecimal string of at least  
     | 
| 
       208 
     | 
    
         
            -
                          "The value that you've provided, \"#{@ 
     | 
| 
       209 
     | 
    
         
            -
                          "#{@ 
     | 
| 
       210 
     | 
    
         
            -
                          "generated) string as  
     | 
| 
       211 
     | 
    
         
            -
                           
     | 
| 
      
 207 
     | 
    
         
            +
                          "hexadecimal string of at least #{@data_cipher.key_len} bytes. " +
         
     | 
| 
      
 208 
     | 
    
         
            +
                          "The value that you've provided, \"#{@secret}\", is " +
         
     | 
| 
      
 209 
     | 
    
         
            +
                          "#{@secret.size / 2} bytes. You could use the following (randomly " +
         
     | 
| 
      
 210 
     | 
    
         
            +
                          "generated) string as the secret: " +
         
     | 
| 
      
 211 
     | 
    
         
            +
                          SecureRandom.hex(@data_cipher.key_len)
         
     | 
| 
       212 
212 
     | 
    
         
             
                    end
         
     | 
| 
       213 
213 
     | 
    
         
             
                  end
         
     | 
| 
       214 
214 
     | 
    
         |