mumukit-login 7.1.1 → 7.4.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f422707e8eea054a21834b6eabb5dbd3b05a3377fdb9b92b535930c57c481c0a
4
- data.tar.gz: ccddd35d16e208dc05480aef339f873b7efc62896c517592735d1a999da1516d
3
+ metadata.gz: 9936c36470aad69a4573c77067305f4f1cc689657f3e853cad2c67fa9cf655db
4
+ data.tar.gz: 13566888f54e440dd75d6122262aaf66cd8e4e817d35433db9d1a62565172b94
5
5
  SHA512:
6
- metadata.gz: b3a1f0475077b97e231aea878ff9ac6458169dcb2655e12c5833534d5147fe3961ae7832d60f7bef30e65c6005914699426efc437d11c85bcd837abdd0eb110c
7
- data.tar.gz: dba412a31851abbeea17ff776be7b921d8a0b4c08c9f10f23b4aaf8cc7ade9715d61bdb84aa9b8e581e833d0f74752611daaaaa3fad66a3703de617f71ed605e
6
+ metadata.gz: 416fd94bf5d2344ea837a8edca52ef9e023b72e4b7b67af45a70c5bd6d4b95a0d456d5f0260c207a0a41a2ee714569998ebdb117da1816c6d6064d09bedcf39d
7
+ data.tar.gz: 8f7bd5f3152b4624de431567f937facb9a57cdb2c7fd5782c970ad4e8db034e9c11671cb000a8e9361f25542b6a1c7f609664b65eccdedca12eaef7fa00fc657
@@ -19,6 +19,7 @@ module Mumukit::Login::LoginControllerHelpers
19
19
 
20
20
  def logout_current_user!
21
21
  destroy_current_user_session!
22
+ login_provider.destroy_session! mumukit_controller
22
23
  origin_redirector.redirect_after_logout!
23
24
  end
24
25
 
@@ -6,11 +6,10 @@ class Mumukit::Login::Mucookie
6
6
  end
7
7
 
8
8
  def write!(key, value, options={})
9
- @controller.write_cookie! cookie_name(key),
10
- spec.merge(
11
- value: value.to_s,
12
- httponly: !!options[:httponly],
13
- same_site: self.class.cookie_same_site)
9
+ do_write! cookie_name(key),
10
+ spec.merge(
11
+ value: value.to_s,
12
+ httponly: !!options[:httponly])
14
13
  end
15
14
 
16
15
  def encrypt_and_write!(key, value, options={})
@@ -22,7 +21,7 @@ class Mumukit::Login::Mucookie
22
21
  end
23
22
 
24
23
  def read(key)
25
- @controller.read_cookie cookie_name(key)
24
+ do_read!(cookie_name(key))
26
25
  end
27
26
 
28
27
  def decrypt_and_read(key)
@@ -34,7 +33,7 @@ class Mumukit::Login::Mucookie
34
33
  end
35
34
 
36
35
  def delete!(key)
37
- @controller.delete_cookie! cookie_name(key), Mumukit::Login.config.mucookie_domain
36
+ do_delete! cookie_name(key), Mumukit::Login.config.mucookie_domain
38
37
  end
39
38
 
40
39
  def spec
@@ -55,6 +54,22 @@ class Mumukit::Login::Mucookie
55
54
 
56
55
  private
57
56
 
57
+ # Support for legacy browsers
58
+ # Duplicate write / read / delete cookies without samesite for old browsers that do not allow for SameSite=None attribute
59
+ def do_write!(cookie_name, spec)
60
+ @controller.write_cookie! cookie_name, spec.merge(same_site: self.class.cookie_same_site)
61
+ @controller.write_cookie! "#{cookie_name}_legacy", spec
62
+ end
63
+
64
+ def do_delete!(cookie_name, domain)
65
+ @controller.delete_cookie! cookie_name, domain
66
+ @controller.delete_cookie! "#{cookie_name}_legacy", domain
67
+ end
68
+
69
+ def do_read!(cookie_name)
70
+ @controller.read_cookie(cookie_name) || @controller.read_cookie("#{cookie_name}_legacy")
71
+ end
72
+
58
73
  def cookie_name(key)
59
74
  "mucookie_#{key}"
60
75
  end
@@ -95,5 +110,6 @@ class Mumukit::Login::Mucookie
95
110
  value.try { |it| encryptor.decrypt_and_verify it }
96
111
  end
97
112
  end
98
-
99
113
  end
114
+
115
+ require_relative 'mucookie/store'
@@ -0,0 +1,14 @@
1
+ require 'action_dispatch'
2
+
3
+ class Mumukit::Login::Mucookie::Store < ActionDispatch::Session::CookieStore
4
+ def set_cookie(request, session_id, cookie)
5
+ cookie.merge! same_site: :none if on_embeddable_organization?(request)
6
+ super
7
+ end
8
+
9
+ private
10
+
11
+ def on_embeddable_organization?(request)
12
+ Mumukit::Platform::Organization.find_by_name!(request.cookies['mucookie_login_organization']).embeddable? rescue false
13
+ end
14
+ end
@@ -1,15 +1,21 @@
1
1
  module Mumukit::Login::Profile
2
2
  def self.from_omniauth(omniauth)
3
- struct provider: omniauth.provider,
4
- first_name: omniauth.info.first_name,
5
- last_name: omniauth.info.last_name,
6
- social_id: omniauth.uid,
7
- email: omniauth.info.email,
8
- uid: generate_uid(omniauth),
9
- image_url: omniauth.info.image
3
+ struct profile_hash(omniauth)
4
+ end
5
+
6
+ def self.profile_hash(omniauth)
7
+ {
8
+ provider: omniauth.provider,
9
+ first_name: omniauth.info.first_name,
10
+ last_name: omniauth.info.last_name,
11
+ social_id: omniauth.uid,
12
+ email: omniauth.info.email,
13
+ uid: generate_uid(omniauth),
14
+ image_url: omniauth.info.image
15
+ }.compact
10
16
  end
11
17
 
12
18
  def self.generate_uid(omniauth)
13
- omniauth.info.email || omniauth.uid
19
+ Mumukit::Login::Provider.parse_login_provider(omniauth.provider).uid_for_profile(omniauth)
14
20
  end
15
21
  end
@@ -46,7 +46,7 @@ module Mumukit::Login::Provider
46
46
  end
47
47
 
48
48
  def self.parse_login_provider(login_provider)
49
- if enabled_providers.include? login_provider
49
+ if enabled_providers.include?(login_provider.to_s)
50
50
  "Mumukit::Login::Provider::#{login_provider.capitalize}".constantize.new
51
51
  else
52
52
  raise "Unknown login_provider `#{login_provider}`"
@@ -45,6 +45,9 @@ class Mumukit::Login::Provider::Base
45
45
  nil
46
46
  end
47
47
 
48
+ def destroy_session!(_controller)
49
+ end
50
+
48
51
  def setup_proc
49
52
  proc do |env|
50
53
  options = env['omniauth.strategy'].options
@@ -75,6 +78,13 @@ class Mumukit::Login::Provider::Base
75
78
  {}
76
79
  end
77
80
 
81
+ def finalize_user_creation!(_user)
82
+ end
83
+
84
+ def uid_for_profile(omniauth)
85
+ omniauth.info.email || omniauth.uid
86
+ end
87
+
78
88
  private
79
89
 
80
90
  def setup_phase_login_settings(env)
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  module Login
3
- VERSION = '7.1.1'
3
+ VERSION = '7.4.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mumukit-login
3
3
  version: !ruby/object:Gem::Version
4
- version: 7.1.1
4
+ version: 7.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Franco Leonardo Bulgarelli
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-17 00:00:00.000000000 Z
11
+ date: 2020-10-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '10.0'
33
+ version: '12.3'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '10.0'
40
+ version: '12.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '3'
47
+ version: '3.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '3'
54
+ version: '3.0'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: codeclimate-test-reporter
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -234,6 +234,20 @@ dependencies:
234
234
  - - "~>"
235
235
  - !ruby/object:Gem::Version
236
236
  version: '5.0'
237
+ - !ruby/object:Gem::Dependency
238
+ name: actionpack
239
+ requirement: !ruby/object:Gem::Requirement
240
+ requirements:
241
+ - - "~>"
242
+ - !ruby/object:Gem::Version
243
+ version: '5.1'
244
+ type: :runtime
245
+ prerelease: false
246
+ version_requirements: !ruby/object:Gem::Requirement
247
+ requirements:
248
+ - - "~>"
249
+ - !ruby/object:Gem::Version
250
+ version: '5.1'
237
251
  description:
238
252
  email:
239
253
  - franco@mumuki.org
@@ -257,6 +271,7 @@ files:
257
271
  - lib/mumukit/login/helpers/login_settings_helpers.rb
258
272
  - lib/mumukit/login/helpers/organization_helpers.rb
259
273
  - lib/mumukit/login/mucookie.rb
274
+ - lib/mumukit/login/mucookie/store.rb
260
275
  - lib/mumukit/login/origin_redirector.rb
261
276
  - lib/mumukit/login/profile.rb
262
277
  - lib/mumukit/login/provider.rb
@@ -290,8 +305,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
290
305
  - !ruby/object:Gem::Version
291
306
  version: '0'
292
307
  requirements: []
293
- rubyforge_project:
294
- rubygems_version: 2.7.7
308
+ rubygems_version: 3.0.8
295
309
  signing_key:
296
310
  specification_version: 4
297
311
  summary: Library for login mumuki requests