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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14d5793f35913b63f422a4cc5c0ecf4eca2caea6
4
- data.tar.gz: 50d025d89a7a996204448d8c94a4b8b5c2b2bfcc
3
+ metadata.gz: 902d9f02e6d86c98d95c2fe8ca85cb2524d0d93b
4
+ data.tar.gz: 7e56291ccb737692f32719f21d0b06b9a4f0ea48
5
5
  SHA512:
6
- metadata.gz: e0229026ebdd636d0c806cd621bff1708f52514dc5d10c2855a4613918b2c00edf02e655b7260ac17671117da98627fc8fdeef9222b749fa844d774e9b6ad740
7
- data.tar.gz: 537fa554c4835f72f7b864c6c70d28513bc2042ca30e0cefaed53c2757caed6115e30b0a23814c84dc2dbaff479cf4d33785633fbe34759468f923b1c334458c
6
+ metadata.gz: a87e029c0bd2155300eda9945104c265975055cfd296da92d40854bac1dc88796e6878dbd227af2fec86e0ab08e25ed5a56697dc6f7355432dc058dc01743685
7
+ data.tar.gz: 4f9f252b0c983a5191920365d96fd483ec2b0f72ac0950bdbf047bc1f6af069ad909c2c8375f12bd73152eae644c4418f314f964c6f0b4e0ef9cb77c47d1a7fc
@@ -2,6 +2,11 @@
2
2
 
3
3
  ### Master (unreleased)
4
4
 
5
+ ### 0.25.0
6
+
7
+ * Removes support for RubyCAS
8
+ * Adds support for JavaCAS
9
+
5
10
  ### 0.24.3
6
11
 
7
12
  * Fix nav_link helper method. You have to pass '' for script_name option instead of nil.
@@ -41,7 +41,7 @@ class WcmsApplicationController < ActionController::Base
41
41
  end
42
42
 
43
43
  def authenticate!
44
- authentication.perform or render_error_page(401)
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}", formats: [:html], status: status, layout: false
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,3 +1,3 @@
1
1
  module BiolaWcmsComponents
2
- VERSION = "0.24.3"
2
+ VERSION = "0.25.0"
3
3
  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
- if username.present?
8
- @user ||= User.find_or_initialize_by(username: username)
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
- true
15
- elsif present?
16
- if new_user?
17
- if create_user!
18
- authenticate!
19
- end
20
- elsif unauthenticated?
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
- !!user.try(:new_record?)
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
- user.biola_id = extra_attr(:employeeId) if extra_attr_has_key?(:employeeId)
53
- user.first_name = extra_attr(:eduPersonNickname) if extra_attr_has_key?(:eduPersonNickname)
54
- user.last_name = extra_attr(:sn) if extra_attr_has_key?(:sn)
55
- user.email = extra_attr(:mail) if extra_attr_has_key?(:mail)
56
- user.photo_url = extra_attr(:url) if extra_attr_has_key?(:url)
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 :create_user! :update_extra_attributes!
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 extra_attributes
72
- @extra_attributes ||= (attrs['extra_attributes'] || {}).with_indifferent_access
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.24.3
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: 2016-10-31 00:00:00.000000000 Z
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.6.1
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