Class: Mumukit::Login::Mucookie
- Inherits:
-
Object
- Object
- Mumukit::Login::Mucookie
show all
- Defined in:
- lib/mumukit/login/mucookie.rb
Defined Under Namespace
Modules: Encryptor
Classes: Store
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(controller) ⇒ Mucookie
Returns a new instance of Mucookie.
4
5
6
|
# File 'lib/mumukit/login/mucookie.rb', line 4
def initialize(controller)
@controller = controller
end
|
Class Method Details
.cookie_same_site ⇒ Object
47
48
49
50
51
52
53
|
# File 'lib/mumukit/login/mucookie.rb', line 47
def self.cookie_same_site
if %w(RACK_ENV RAILS_ENV).any? { |it| ENV[it] == 'production' }
:none
else
:lax
end
end
|
Instance Method Details
#decode_and_read(key) ⇒ Object
31
32
33
|
# File 'lib/mumukit/login/mucookie.rb', line 31
def decode_and_read(key)
Base64.decode64 read(key)
end
|
#decrypt_and_read(key) ⇒ Object
27
28
29
|
# File 'lib/mumukit/login/mucookie.rb', line 27
def decrypt_and_read(key)
Encryptor.decrypt read(key)
end
|
#delete!(key) ⇒ Object
35
36
37
|
# File 'lib/mumukit/login/mucookie.rb', line 35
def delete!(key)
do_delete! cookie_name(key), Mumukit::Login.config.mucookie_domain
end
|
#encode_and_write!(key, value, options = {}) ⇒ Object
19
20
21
|
# File 'lib/mumukit/login/mucookie.rb', line 19
def encode_and_write!(key, value, options={})
write! key, Base64.encode64(value), options
end
|
#encrypt_and_write!(key, value, options = {}) ⇒ Object
15
16
17
|
# File 'lib/mumukit/login/mucookie.rb', line 15
def encrypt_and_write!(key, value, options={})
write! key, Encryptor.encrypt(value), options
end
|
#read(key) ⇒ Object
23
24
25
|
# File 'lib/mumukit/login/mucookie.rb', line 23
def read(key)
do_read!(cookie_name(key))
end
|
#spec ⇒ Object
39
40
41
42
43
44
45
|
# File 'lib/mumukit/login/mucookie.rb', line 39
def spec
{
path: '/',
expires: Mumukit::Login.config.mucookie_duration.days.since,
domain: Mumukit::Login.config.mucookie_domain
}
end
|
#write!(key, value, options = {}) ⇒ Object
8
9
10
11
12
13
|
# File 'lib/mumukit/login/mucookie.rb', line 8
def write!(key, value, options={})
do_write! cookie_name(key),
spec.merge(
value: value.to_s,
httponly: !!options[:httponly])
end
|