biola_wcms_components 0.25.0 → 0.25.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/biola_wcms_components/version.rb +1 -1
- data/lib/components/cas_authentication.rb +27 -15
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5f29ca233d7b9c38afa355bd466d740f5b2188ba
|
4
|
+
data.tar.gz: b771c11af719e321462160be334c0d2e89ed515e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 924c1c3508a2f0362586af92b03f981d1cdaf9654689116bc60c86b5df97bd97912e883a3cc97864e647a0bb00271f916ba4f11de501e1d29d7ce8362f5db4a6
|
7
|
+
data.tar.gz: c809523c4be832ad7e473cc3e89afc35efaac121fcd96c77f8bfe05a4cbbb728d4577a03ea7eea47492122c52612c4b07acea56a946c2cf33c3a03c871370122
|
data/CHANGELOG.md
CHANGED
@@ -5,16 +5,6 @@ class CasAuthentication
|
|
5
5
|
@session = session
|
6
6
|
end
|
7
7
|
|
8
|
-
USER_CAS_MAP = {
|
9
|
-
biola_id: :employeeId,
|
10
|
-
first_name: :eduPersonNickname,
|
11
|
-
last_name: :sn,
|
12
|
-
email: :mail,
|
13
|
-
photo_url: :url,
|
14
|
-
entitlements: :eduPersonEntitlement,
|
15
|
-
affiliations: :eduPersonAffiliation
|
16
|
-
}.freeze
|
17
|
-
|
18
8
|
def user
|
19
9
|
return unless username.present?
|
20
10
|
@user ||= User.find_or_initialize_by(username: username)
|
@@ -36,6 +26,16 @@ class CasAuthentication
|
|
36
26
|
|
37
27
|
attr_reader :session
|
38
28
|
|
29
|
+
USER_CAS_MAP = {
|
30
|
+
biola_id: { employeeId: Integer },
|
31
|
+
first_name: :eduPersonNickname,
|
32
|
+
last_name: :sn,
|
33
|
+
email: :mail,
|
34
|
+
photo_url: :url,
|
35
|
+
entitlements: { eduPersonEntitlement: Array },
|
36
|
+
affiliations: { eduPersonAffiliation: Array }
|
37
|
+
}.freeze
|
38
|
+
|
39
39
|
def present?
|
40
40
|
session['cas'].present?
|
41
41
|
end
|
@@ -58,23 +58,35 @@ class CasAuthentication
|
|
58
58
|
|
59
59
|
def update_extra_attributes!
|
60
60
|
USER_CAS_MAP.each do |k, v|
|
61
|
-
|
62
|
-
user[k] = value unless value.blank?
|
61
|
+
user[k] = attr_value(v, extra_attrs)
|
63
62
|
end
|
64
|
-
|
65
63
|
user.save
|
66
64
|
end
|
67
65
|
alias create_user! update_extra_attributes!
|
68
66
|
|
69
67
|
def username
|
70
|
-
(session[:username] || attrs[
|
68
|
+
(session[:username] || attrs[:user]).downcase
|
71
69
|
end
|
72
70
|
|
73
71
|
def attrs
|
74
|
-
@attrs ||= (session[
|
72
|
+
@attrs ||= (session[:cas] || {}).with_indifferent_access
|
75
73
|
end
|
76
74
|
|
77
75
|
def extra_attrs
|
78
76
|
@extra_attrs ||= (attrs[:extra_attributes] || {}).with_indifferent_access
|
79
77
|
end
|
78
|
+
|
79
|
+
def attr_value(key, opts = {})
|
80
|
+
return String(opts[key]) if key.is_a? Symbol
|
81
|
+
attr_hash(key, opts)
|
82
|
+
end
|
83
|
+
|
84
|
+
def attr_hash(hash, opts = {})
|
85
|
+
return unless hash.is_a? Hash
|
86
|
+
|
87
|
+
key, type = hash.first
|
88
|
+
return Array(opts.try(:[], key)).compact if type == Array
|
89
|
+
return Integer(opts.try(:[], key)) if type == Integer &&
|
90
|
+
/\A\d+\z/ =~ opts[key].to_s
|
91
|
+
end
|
80
92
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: biola_wcms_components
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.25.
|
4
|
+
version: 0.25.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Hall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ace-rails-ap
|