Module: Mumukit::Login::Mucookie::Encryptor
- Defined in:
- lib/mumukit/login/mucookie.rb
Class Method Summary collapse
Class Method Details
.decrypt(value) ⇒ Object
75 76 77 |
# File 'lib/mumukit/login/mucookie.rb', line 75 def self.decrypt(value) value.try { |it| encryptor.decrypt_and_verify it } end |
.encrypt(value) ⇒ Object
71 72 73 |
# File 'lib/mumukit/login/mucookie.rb', line 71 def self.encrypt(value) encryptor.encrypt_and_sign value end |
.encryptor ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/mumukit/login/mucookie.rb', line 57 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
47 48 49 50 51 52 53 54 55 |
# File 'lib/mumukit/login/mucookie.rb', line 47 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 |