Module: Mumukit::Login::Mucookie::Encryptor
- Defined in:
- lib/mumukit/login/mucookie.rb
Constant Summary collapse
- MESSAGE_ENCRYPTOR_SECRET_SIZE =
message encryptor requires a 32-byte key
32
Class Method Summary collapse
Class Method Details
.decrypt(value) ⇒ Object
94 95 96 |
# File 'lib/mumukit/login/mucookie.rb', line 94 def self.decrypt(value) value.try { |it| encryptor.decrypt_and_verify it } end |
.encrypt(value) ⇒ Object
90 91 92 |
# File 'lib/mumukit/login/mucookie.rb', line 90 def self.encrypt(value) encryptor.encrypt_and_sign value end |
.encryptor ⇒ Object
76 77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/mumukit/login/mucookie.rb', line 76 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(, MESSAGE_ENCRYPTOR_SECRET_SIZE) signature = key_generator.generate_key() ActiveSupport::MessageEncryptor.new(secret, signature) end end |
.key_generator ⇒ Object
66 67 68 69 70 71 72 73 74 |
# File 'lib/mumukit/login/mucookie.rb', line 66 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 |