ucb_rails 0.0.6 → 0.0.7
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.
- data/app/controllers/ucb_rails/admin/configuration_controller.rb +7 -0
- data/app/controllers/ucb_rails/sessions_controller.rb +1 -1
- data/app/models/ucb_rails/configuration/cas.rb +53 -0
- data/app/models/ucb_rails/configuration/ldap.rb +40 -0
- data/app/models/ucb_rails/user.rb +9 -0
- data/app/views/ucb_rails/admin/configuration/index.html.haml +47 -0
- data/config/routes.rb +1 -0
- data/lib/generators/ucb_rails/templates/app/assets/javascripts/ucb_rails/users_datatable.js +1 -1
- data/lib/generators/ucb_rails/templates/app/views/layouts/_developer.html.haml +2 -1
- data/lib/generators/ucb_rails/templates/config/config.yml.example +12 -2
- data/lib/generators/ucb_rails/templates/config/initializers/local/ucb_rails.rb +7 -14
- data/lib/ucb_rails/version.rb +1 -1
- metadata +6 -2
@@ -55,7 +55,7 @@ class UcbRails::SessionsController < ApplicationController
|
|
55
55
|
|
56
56
|
def redirect_url(provider)
|
57
57
|
if provider.to_s == 'cas'
|
58
|
-
"http
|
58
|
+
"http://#{UcbRails[:cas_host]}/cas/logout?url=#{root_url}"
|
59
59
|
else
|
60
60
|
root_path
|
61
61
|
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
module UcbRails
|
2
|
+
module Configuration
|
3
|
+
|
4
|
+
class Cas
|
5
|
+
attr_accessor :config
|
6
|
+
|
7
|
+
def initialize(config)
|
8
|
+
self.config = config.presence || {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def configure
|
12
|
+
configure_omniauth
|
13
|
+
set_ucb_rails_cas_host
|
14
|
+
end
|
15
|
+
|
16
|
+
def configure_omniauth
|
17
|
+
host_name = host
|
18
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
19
|
+
|
20
|
+
unless RailsEnvironment.production?
|
21
|
+
provider(:developer, fields: [:uid], uid_field: :uid)
|
22
|
+
end
|
23
|
+
|
24
|
+
provider :cas,
|
25
|
+
host: host_name,
|
26
|
+
login_url: '/cas/login',
|
27
|
+
service_validate_url: '/cas/serviceValidate'
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def set_ucb_rails_cas_host
|
32
|
+
UcbRails.config.cas_host = host
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def host
|
38
|
+
config.fetch('host', default_host)
|
39
|
+
end
|
40
|
+
|
41
|
+
def default_host
|
42
|
+
RailsEnvironment.production? ? 'auth.berkeley.edu' : 'auth-test.berkeley.edu'
|
43
|
+
end
|
44
|
+
|
45
|
+
class << self
|
46
|
+
def configure(config)
|
47
|
+
new(config).configure
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
53
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module UcbRails
|
2
|
+
module Configuration
|
3
|
+
|
4
|
+
class Ldap
|
5
|
+
attr_accessor :config
|
6
|
+
|
7
|
+
def initialize(config)
|
8
|
+
self.config = config.presence || {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def configure
|
12
|
+
configure_host
|
13
|
+
authenticate
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def configure_host
|
19
|
+
UCB::LDAP.host = config.fetch('host', default_host)
|
20
|
+
end
|
21
|
+
|
22
|
+
def authenticate
|
23
|
+
if config.has_key?('username')
|
24
|
+
UCB::LDAP.authenticate config['username'], config['password']
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def default_host
|
29
|
+
RailsEnvironment.production? ? 'nds.berkeley.edu' : 'nds-test.berkeley.edu'
|
30
|
+
end
|
31
|
+
|
32
|
+
class << self
|
33
|
+
def configure(config)
|
34
|
+
new(config).configure
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
%h1 Configuration
|
2
|
+
|
3
|
+
%h2 config/config.yml
|
4
|
+
|
5
|
+
- config = UcbRails::Configuration::Configuration.new
|
6
|
+
%pre
|
7
|
+
= preserve do
|
8
|
+
= config.config_yaml.to_yaml
|
9
|
+
|
10
|
+
%h2 LDAP
|
11
|
+
|
12
|
+
%pre
|
13
|
+
= preserve do
|
14
|
+
= ["host: #{UCB::LDAP.host}", "username: #{UCB::LDAP.username}", "password: #{UCB::LDAP.password}"].join("\n")
|
15
|
+
|
16
|
+
%h2 Email
|
17
|
+
|
18
|
+
%table{border: 1, cellpadding: '4px', cellspacing: 0}
|
19
|
+
%tr
|
20
|
+
%th Key
|
21
|
+
%th Value
|
22
|
+
%tr
|
23
|
+
%td default
|
24
|
+
%td= ActionMailer::Base.default.inspect
|
25
|
+
%tr
|
26
|
+
%td default_url_options
|
27
|
+
%td= ActionMailer::Base.default_url_options.inspect
|
28
|
+
%tr
|
29
|
+
%td delivery method
|
30
|
+
%td= ActionMailer::Base.delivery_method.inspect
|
31
|
+
%tr
|
32
|
+
%td raise delivery errors
|
33
|
+
%td= ActionMailer::Base.raise_delivery_errors.inspect
|
34
|
+
%tr
|
35
|
+
%td sendmail_settings
|
36
|
+
%td= ActionMailer::Base.sendmail_settings.inspect
|
37
|
+
%tr
|
38
|
+
%td smtp_settings
|
39
|
+
%td= ActionMailer::Base.smtp_settings.inspect
|
40
|
+
%tr
|
41
|
+
%td subject prefix
|
42
|
+
%td= UcbRails[:email_subject_prefix]
|
43
|
+
|
44
|
+
%h2 Exception Notifier
|
45
|
+
|
46
|
+
%pre
|
47
|
+
= config.for('exception_notifier')
|
data/config/routes.rb
CHANGED
@@ -11,7 +11,7 @@ $(function() {
|
|
11
11
|
"oLanguage": {
|
12
12
|
"sSearch": "First or Last Name starts with:"
|
13
13
|
},
|
14
|
-
"aLengthMenu": [[
|
14
|
+
"aLengthMenu": [[20, 50, 100, 1000], [20, 50, 100, 1000]],
|
15
15
|
"aaSorting": [[ 5, "desc" ]],
|
16
16
|
"aoColumnDefs": [
|
17
17
|
{ "aDataSort": [ 0, 2, 3 ], "aTargets": [ 0 ] }, // admin
|
@@ -1,5 +1,6 @@
|
|
1
1
|
= nav_dropdown("Developer") do
|
2
|
-
= dropdown_item(
|
2
|
+
= dropdown_item(icon('cog', "Configuration"), ucb_rails_admin_configuration_path)
|
3
|
+
= dropdown_item(icon('picture', "Bootstrap Examples"), bvh_path)
|
3
4
|
= dropdown_item(icon('exclamation-sign', "Force Exception"), ucb_rails_admin_force_exception_path)
|
4
5
|
|
5
6
|
- if RailsEnvironment.development?
|
@@ -1,14 +1,20 @@
|
|
1
1
|
# You can have configuration per-environment by nesting under the
|
2
2
|
# environment key, or have a top level.
|
3
3
|
|
4
|
-
|
5
|
-
|
6
4
|
# ldap:
|
5
|
+
# host: 'nds.berkeley.edu'
|
6
|
+
# host: 'nds-test.berkeley.edu'
|
7
7
|
# username: <username>
|
8
8
|
# password: <password>
|
9
9
|
|
10
10
|
development:
|
11
11
|
|
12
|
+
# Default behavior will do the right thing. Only set if you want
|
13
|
+
# non-standard behavior.
|
14
|
+
# cas:
|
15
|
+
# host: 'auth.berkeley.edu'
|
16
|
+
# host: 'auth-test.berkeley.edu'
|
17
|
+
|
12
18
|
# email:
|
13
19
|
# default:
|
14
20
|
# from: user@gmail.com
|
@@ -40,7 +46,11 @@ development:
|
|
40
46
|
# - user1@example.com
|
41
47
|
# - user2@example.com
|
42
48
|
|
49
|
+
# Default behavior will select the correct host. No need to set anything if
|
50
|
+
# you aren't specifying username/password.
|
43
51
|
# ldap:
|
52
|
+
# host: 'nds.berkeley.edu'
|
53
|
+
# host: 'nds-test.berkeley.edu'
|
44
54
|
# username: <username>
|
45
55
|
# password: <password>
|
46
56
|
|
@@ -20,24 +20,17 @@ UcbRails::Configuration::ExceptionNotification.configure(config.for('exception_n
|
|
20
20
|
# UCB::LDAP
|
21
21
|
############################################################
|
22
22
|
|
23
|
-
|
24
|
-
|
25
|
-
puts "[UcbRails] Using ldap credentials from #{config.config_filename}"
|
26
|
-
UCB::LDAP.authenticate(ldap_credentials['username'], ldap_credentials['password'])
|
27
|
-
else
|
28
|
-
puts "[UcbRails] No ldap credentials found. Using anonymous bind."
|
29
|
-
end
|
30
|
-
|
23
|
+
UcbRails::Configuration::Ldap.configure(config.for('ldap'))
|
24
|
+
|
31
25
|
############################################################
|
32
26
|
# OmniAuth
|
33
27
|
############################################################
|
34
28
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
29
|
+
UcbRails::Configuration::Cas.configure(config.for('cas'))
|
30
|
+
|
31
|
+
############################################################
|
32
|
+
# UcbRails
|
33
|
+
############################################################
|
41
34
|
|
42
35
|
UcbRails.config do |config|
|
43
36
|
|
data/lib/ucb_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ucb_rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-06-
|
12
|
+
date: 2013-06-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -563,6 +563,7 @@ extensions: []
|
|
563
563
|
extra_rdoc_files: []
|
564
564
|
files:
|
565
565
|
- app/controllers/ucb_rails/admin/base_controller.rb
|
566
|
+
- app/controllers/ucb_rails/admin/configuration_controller.rb
|
566
567
|
- app/controllers/ucb_rails/admin/force_exception_controller.rb
|
567
568
|
- app/controllers/ucb_rails/admin/users_controller.rb
|
568
569
|
- app/controllers/ucb_rails/bootstrap_controller.rb
|
@@ -581,9 +582,11 @@ files:
|
|
581
582
|
- app/helpers/ucb_rails/renderer/ldap_person_search_result_link.rb
|
582
583
|
- app/helpers/ucb_rails/renderer/lps_typeahead_search_field.rb
|
583
584
|
- app/mailers/ucb_rails/test_mailer.rb
|
585
|
+
- app/models/ucb_rails/configuration/cas.rb
|
584
586
|
- app/models/ucb_rails/configuration/configuration.rb
|
585
587
|
- app/models/ucb_rails/configuration/email.rb
|
586
588
|
- app/models/ucb_rails/configuration/exception_notification.rb
|
589
|
+
- app/models/ucb_rails/configuration/ldap.rb
|
587
590
|
- app/models/ucb_rails/ldap_person/entry.rb
|
588
591
|
- app/models/ucb_rails/ldap_person/finder.rb
|
589
592
|
- app/models/ucb_rails/ldap_person/test_finder.rb
|
@@ -596,6 +599,7 @@ files:
|
|
596
599
|
- app/models/ucb_rails/user_session_manager/in_people_ou_add_to_users_table.rb
|
597
600
|
- app/models/ucb_rails/user_session_manager/ldap_person_user_wrapper.rb
|
598
601
|
- app/models/ucb_rails/user_typeahead.rb
|
602
|
+
- app/views/ucb_rails/admin/configuration/index.html.haml
|
599
603
|
- app/views/ucb_rails/admin/users/_form.html.haml
|
600
604
|
- app/views/ucb_rails/admin/users/_user.html.haml
|
601
605
|
- app/views/ucb_rails/admin/users/edit.html.haml
|