Module: Mumukit::Login::Mucookie::Encryptor
- Defined in:
- lib/mumukit/login/mucookie.rb
Class Method Summary collapse
Class Method Details
.decrypt(value) ⇒ Object
76 77 78 |
# File 'lib/mumukit/login/mucookie.rb', line 76 def self.decrypt(value) value.try { |it| encryptor.decrypt_and_verify it } end |
.encrypt(value) ⇒ Object
72 73 74 |
# File 'lib/mumukit/login/mucookie.rb', line 72 def self.encrypt(value) encryptor.encrypt_and_sign value end |
.encryptor ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/mumukit/login/mucookie.rb', line 58 def self.encryptor @encryptor ||= begin = Mumukit::Login.config. = Mumukit::Login.config. raise 'missing Mumukit::Login.config.mucookie_secret_salt' unless raise 'missing Mumukit::Login.config.mucookie_sign_salt' unless secret = key_generator.generate_key() signature = key_generator.generate_key() ActiveSupport::MessageEncryptor.new(secret, signature) end end |
.key_generator ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/mumukit/login/mucookie.rb', line 48 def self.key_generator @key_generator ||= begin secret_key = Mumukit::Login.config. raise 'missing Mumukit::Login.config.mucookie_secret_key' unless secret_key ActiveSupport::CachingKeyGenerator.new(ActiveSupport::KeyGenerator.new(secret_key, iterations: 1000)) end end |