biola_wcms_components 0.24.3 → 0.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/app/controllers/wcms_application_controller.rb +5 -3
- data/lib/biola_wcms_components/version.rb +1 -1
- data/lib/components/cas_authentication.rb +32 -39
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 902d9f02e6d86c98d95c2fe8ca85cb2524d0d93b
|
4
|
+
data.tar.gz: 7e56291ccb737692f32719f21d0b06b9a4f0ea48
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a87e029c0bd2155300eda9945104c265975055cfd296da92d40854bac1dc88796e6878dbd227af2fec86e0ab08e25ed5a56697dc6f7355432dc058dc01743685
|
7
|
+
data.tar.gz: 4f9f252b0c983a5191920365d96fd483ec2b0f72ac0950bdbf047bc1f6af069ad909c2c8375f12bd73152eae644c4418f314f964c6f0b4e0ef9cb77c47d1a7fc
|
data/CHANGELOG.md
CHANGED
@@ -41,7 +41,7 @@ class WcmsApplicationController < ActionController::Base
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def authenticate!
|
44
|
-
authentication.perform
|
44
|
+
authentication.perform || render_error_page(401)
|
45
45
|
end
|
46
46
|
|
47
47
|
def authentication
|
@@ -49,11 +49,13 @@ class WcmsApplicationController < ActionController::Base
|
|
49
49
|
end
|
50
50
|
|
51
51
|
def render_error_page(status)
|
52
|
-
render file: "#{Rails.root}/public/#{status}",
|
52
|
+
render file: "#{Rails.root}/public/#{status}",
|
53
|
+
formats: [:html],
|
54
|
+
status: status,
|
55
|
+
layout: false
|
53
56
|
end
|
54
57
|
|
55
58
|
def user_not_authorized
|
56
59
|
render_error_page(403)
|
57
60
|
end
|
58
|
-
|
59
61
|
end
|
@@ -1,26 +1,34 @@
|
|
1
|
+
##
|
2
|
+
# Authenticate User and Create Session
|
1
3
|
class CasAuthentication
|
2
4
|
def initialize(session)
|
3
5
|
@session = session
|
4
6
|
end
|
5
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
|
+
|
6
18
|
def user
|
7
|
-
|
8
|
-
|
9
|
-
end
|
19
|
+
return unless username.present?
|
20
|
+
@user ||= User.find_or_initialize_by(username: username)
|
10
21
|
end
|
11
22
|
|
12
23
|
def perform
|
13
|
-
if authenticated?
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
authenticate!
|
22
|
-
update_extra_attributes!
|
23
|
-
end
|
24
|
+
return true if authenticated?
|
25
|
+
return unless session['cas'].present?
|
26
|
+
|
27
|
+
if new_user?
|
28
|
+
authenticate! if create_user!
|
29
|
+
elsif unauthenticated?
|
30
|
+
authenticate!
|
31
|
+
update_extra_attributes!
|
24
32
|
end
|
25
33
|
end
|
26
34
|
|
@@ -33,7 +41,7 @@ class CasAuthentication
|
|
33
41
|
end
|
34
42
|
|
35
43
|
def new_user?
|
36
|
-
|
44
|
+
user.try(:new_record?)
|
37
45
|
end
|
38
46
|
|
39
47
|
def authenticated?
|
@@ -49,39 +57,24 @@ class CasAuthentication
|
|
49
57
|
end
|
50
58
|
|
51
59
|
def update_extra_attributes!
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
user.entitlements = extra_attrs(:eduPersonEntitlement) if extra_attr_has_key?(:eduPersonEntitlement)
|
58
|
-
user.affiliations = extra_attrs(:eduPersonAffiliation) if extra_attr_has_key?(:eduPersonAffiliation)
|
60
|
+
USER_CAS_MAP.each do |k, v|
|
61
|
+
value = extra_attrs.fetch(v, nil)
|
62
|
+
user[k] = value unless value.blank?
|
63
|
+
end
|
64
|
+
|
59
65
|
user.save
|
60
66
|
end
|
61
|
-
alias
|
67
|
+
alias create_user! update_extra_attributes!
|
62
68
|
|
63
69
|
def username
|
64
|
-
session[:username] || attrs['user']
|
70
|
+
(session[:username] || attrs['user']).downcase
|
65
71
|
end
|
66
72
|
|
67
73
|
def attrs
|
68
74
|
@attrs ||= (session['cas'] || {}).with_indifferent_access
|
69
75
|
end
|
70
76
|
|
71
|
-
def
|
72
|
-
@
|
73
|
-
end
|
74
|
-
|
75
|
-
def extra_attr_has_key?(key)
|
76
|
-
extra_attributes.has_key? key
|
77
|
-
end
|
78
|
-
|
79
|
-
def extra_attr(key)
|
80
|
-
# Many values come back as arrays but don't really need to be
|
81
|
-
extra_attrs(key).first
|
82
|
-
end
|
83
|
-
|
84
|
-
def extra_attrs(key)
|
85
|
-
Array(extra_attributes[key]).map(&:to_s)
|
77
|
+
def extra_attrs
|
78
|
+
@extra_attrs ||= (attrs[:extra_attributes] || {}).with_indifferent_access
|
86
79
|
end
|
87
80
|
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.
|
4
|
+
version: 0.25.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Hall
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2017-09-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ace-rails-ap
|
@@ -310,7 +310,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
310
310
|
version: '0'
|
311
311
|
requirements: []
|
312
312
|
rubyforge_project:
|
313
|
-
rubygems_version: 2.
|
313
|
+
rubygems_version: 2.2.3
|
314
314
|
signing_key:
|
315
315
|
specification_version: 4
|
316
316
|
summary: Reusable UX components for use in or WCMS projects
|