Sha256: 13565385786742c7aa3dfe995ec02277d8aa07898ea8fa1ef2753df56743706b

Contents?: true

Size: 720 Bytes

Versions: 67

Compression:

Stored size: 720 Bytes

Contents

require 'digest/sha1'
require 'erb'

def site_keys_file
  File.join("config", "initializers", "site_keys.rb")
end

def secure_digest(*args)
  Digest::SHA1.hexdigest(args.flatten.join('--'))
end

def make_token
  secure_digest(Time.now, (1..10).map{ rand.to_s })
end

def make_site_keys_rb
  site_key = secure_digest(Time.now, (1..10).map{ rand.to_s })
  site_key_erb = <<-EOF
# key of 40 chars length
REST_AUTH_SITE_KEY         = '#{site_key}'
REST_AUTH_DIGEST_STRETCHES = 10
EOF
end

namespace :auth do
  namespace :gen do
    desc "Generates config/initializers/site_keys.rb"
    task :site_key do
      file = ENV['file'] || site_keys_file
      File.open(file, "w"){|f| f.write(make_site_keys_rb)}
    end
  end
end

Version data entries

67 entries across 67 versions & 10 rubygems

Version Path
simonmenke-mr_authentication-0.0.1 vendor/plugins/restful-authentication/tasks/auth.rake
smukherjee-openbill-0.1.5 vendor/plugins/restful-authentication/tasks/auth.rake
smukherjee-openbill-0.1.6 vendor/plugins/restful-authentication/tasks/auth.rake
smukherjee-openbill-0.1.7 vendor/plugins/restful-authentication/tasks/auth.rake
rails3-restful-authentication-3.0.1 lib/tasks/auth.rake
tournament-5.0.0 webgui/vendor/plugins/restful_authentication/tasks/auth.rake
jashmenn-restful-authentication-2.0.0.beta1 lib/tasks/auth.rake
restful-authentication-1.2.1 lib/tasks/auth.rake
branston-0.6.6 lib/branston/vendor/plugins/restful_authentication/tasks/auth.rake
branston-0.6.5 lib/branston/vendor/plugins/restful_authentication/tasks/auth.rake
branston-0.6.4 lib/branston/vendor/plugins/restful_authentication/tasks/auth.rake
branston-0.6.3 lib/branston/vendor/plugins/restful_authentication/tasks/auth.rake
branston-0.6.2 lib/branston/vendor/plugins/restful_authentication/tasks/auth.rake
tournament-4.2.0 webgui/vendor/plugins/restful_authentication/tasks/auth.rake
tournament-4.0.2 webgui/vendor/plugins/restful_authentication/tasks/auth.rake
tournament-4.0.0 webgui/vendor/plugins/restful_authentication/tasks/auth.rake
branston-0.6.1 lib/branston/vendor/plugins/restful_authentication/tasks/auth.rake
branston-0.6.0 lib/branston/vendor/plugins/restful_authentication/tasks/auth.rake
tournament-3.3.3 webgui/vendor/plugins/restful_authentication/tasks/auth.rake
tournament-3.3.2 webgui/vendor/plugins/restful_authentication/tasks/auth.rake