contour 2.7.0 → 3.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +11 -0
  3. data/README.md +1 -29
  4. data/app/assets/stylesheets/glyphicon-overrides.scss +13 -0
  5. data/app/assets/stylesheets/opensans.scss +20 -0
  6. data/app/controllers/contour/registrations_controller.rb +1 -10
  7. data/app/controllers/contour/sessions_controller.rb +8 -41
  8. data/app/views/contour/layouts/_menu.html.erb +0 -2
  9. data/app/views/contour/sessions/new.html.erb +32 -46
  10. data/config/routes.rb +0 -5
  11. data/contour.gemspec +0 -3
  12. data/lib/contour.rb +2 -14
  13. data/lib/contour/fixes.rb +0 -3
  14. data/lib/contour/version.rb +3 -3
  15. data/lib/generators/contour/install/install_generator.rb +0 -4
  16. data/lib/generators/contour/install/templates/README +0 -4
  17. data/lib/generators/contour/install/templates/contour.rb +2 -12
  18. data/test/controllers/passwords_controller_test.rb +0 -9
  19. data/test/controllers/registrations_controller_test.rb +0 -14
  20. data/test/controllers/sessions_controller_test.rb +0 -12
  21. data/test/dummy/app/models/user.rb +0 -3
  22. data/test/dummy/config/initializers/contour.rb +2 -12
  23. data/test/dummy/db/development.sqlite3 +0 -0
  24. data/test/dummy/db/migrate/20111203203123_devise_create_users.rb +1 -1
  25. data/test/dummy/db/schema.rb +4 -12
  26. data/test/dummy/db/test.sqlite3 +0 -0
  27. data/test/dummy/test/fixtures/users.yml +1 -1
  28. data/test/models/user_test.rb +0 -4
  29. metadata +5 -71
  30. data/app/assets/stylesheets/glyphicon-overrides.scss.erb +0 -13
  31. data/app/assets/stylesheets/opensans.css.erb +0 -20
  32. data/app/controllers/contour/authentications_controller.rb +0 -57
  33. data/app/models/authentication.rb +0 -4
  34. data/app/models/concerns/contour_authenticatable.rb +0 -12
  35. data/app/models/concerns/contourable.rb +0 -19
  36. data/app/views/contour/authentications/_add_remove_table.html.erb +0 -31
  37. data/app/views/contour/authentications/_authentications.html.erb +0 -3
  38. data/app/views/contour/authentications/_menu.html.erb +0 -10
  39. data/app/views/contour/authentications/destroy.js.erb +0 -1
  40. data/app/views/contour/authentications/index.html.erb +0 -6
  41. data/app/views/contour/layouts/_latest_news.html.erb +0 -17
  42. data/lib/contour/fixes/devise-with-rails-4-2.rb +0 -17
  43. data/lib/contour/fixes/omniauth.rb +0 -110
  44. data/lib/contour/fixes/sass-rails.rb +0 -8
  45. data/lib/generators/contour/install/templates/omniauth.rb +0 -33
  46. data/test/controllers/authentications_controller_test.rb +0 -57
  47. data/test/dummy/config/initializers/omniauth.rb +0 -33
  48. data/test/dummy/db/migrate/20111203203307_create_authentications.rb +0 -11
  49. data/test/dummy/test/fixtures/authentications.yml +0 -16
  50. data/test/models/authentication_test.rb +0 -11
@@ -1,3 +0,0 @@
1
- <div id="authentications">
2
- <%= render partial: 'contour/authentications/add_remove_table' %>
3
- </div>
@@ -1,10 +0,0 @@
1
- <% PROVIDERS.each do |provider| %>
2
- <% provider_name = OmniAuth.config.camelizations[provider.to_s.downcase] || provider.to_s.titleize %>
3
- <% image_name = provider.to_s.downcase %>
4
- <li>
5
- <a href="<%= request.script_name %><%= "/" + OmniAuth.config.path_prefix.split('/').last.to_s %><%= "/" + provider.to_s.downcase %>">
6
- <%= image_tag "contour/#{image_name}_32.png", align: 'absmiddle', height: "28px", title: provider_name %>
7
- <%= provider_name %>
8
- </a>
9
- </li>
10
- <% end %>
@@ -1 +0,0 @@
1
- $("#authentications").html("<%= escape_javascript(render("contour/authentications/add_remove_table")) %>");
@@ -1,6 +0,0 @@
1
- <% @title = "Authentications" %>
2
- <div class="page-header">
3
- <h1><%= @title %></h1>
4
- </div>
5
-
6
- <%= render partial: 'contour/authentications/authentications' %>
@@ -1,17 +0,0 @@
1
- <% unless @news_feed.blank? %>
2
- <div class="page-header">
3
- <h1>
4
- Latest News
5
- <%#= link_to @news_feed.channel.title, @news_feed.channel.link, target: '_blank', class: 'btn btn-xs' %>
6
- </h1>
7
- </div>
8
-
9
- <% @news_feed.items.each_with_index do |item, i| %>
10
- <% if i < Contour.news_feed_items.to_i %>
11
- <div class="well">
12
- <label><%= link_to item.title, item.link, target: '_blank' %></label><br />
13
- <ul style="list-style: none"><li><%= item.description.gsub("[...]", link_to('[read more]', item.link, target: '_blank')).html_safe %></li></ul>
14
- </div>
15
- <% end %>
16
- <% end %>
17
- <% end %>
@@ -1,17 +0,0 @@
1
- module ActionDispatch::Routing
2
- class Mapper
3
-
4
- protected
5
- def with_devise_exclusive_scope(new_path, new_as, options) #:nodoc:
6
- current_scope = @scope.dup
7
-
8
- exclusive = { as: new_as, path: new_path, module: nil }
9
- exclusive.merge!(options.slice(:constraints, :defaults, :options))
10
-
11
- exclusive.each_pair { |key, value| @scope[key] = value }
12
- yield
13
- ensure
14
- @scope = current_scope
15
- end
16
- end
17
- end
@@ -1,110 +0,0 @@
1
- require 'omniauth'
2
- require 'omniauth-ldap'
3
-
4
- # # Overwriting methods from Rack
5
- # # While OmniAuth 1.0.2 fixes the Builder setup, Rack 1.4.0 still responds incorrectly to it's release version.
6
- # # Wait for Rack 1.4.1 or updated version before removing the Builder fixes
7
- # module OmniAuth
8
-
9
- # # class Builder updates for Rack 1.4.0
10
- # class Builder
11
- # def initialize(app = nil,&block)
12
- # @use, @map, @run = [], nil, app
13
- # instance_eval(&block) if block_given?
14
- # end
15
-
16
- # def on_failure(&block)
17
- # OmniAuth.config.on_failure = block
18
- # end
19
-
20
- # def configure(&block)
21
- # OmniAuth.configure(&block)
22
- # end
23
-
24
- # def provider(klass, *args, &block)
25
- # if klass.is_a?(Class)
26
- # middleware = klass
27
- # else
28
- # begin
29
- # middleware = OmniAuth::Strategies.const_get("#{OmniAuth::Utils.camelize(klass.to_s)}")
30
- # rescue NameError
31
- # raise LoadError, "Could not find matching strategy for #{klass.inspect}. You may need to install an additional gem (such as omniauth-#{klass})."
32
- # end
33
- # end
34
-
35
- # use middleware, *args, &block
36
- # end
37
-
38
- # def call(env)
39
- # to_app.call(env)
40
- # end
41
- # end
42
- # end
43
-
44
- # Fix for LDAP Authentication with Domains
45
- module OmniAuth
46
-
47
- # Required to correctly authenticate given bind_dn and LDAP
48
- module LDAP
49
- class Adaptor
50
- class LdapError < StandardError; end
51
- class ConfigurationError < StandardError; end
52
- class AuthenticationError < StandardError; end
53
- class ConnectionError < StandardError; end
54
-
55
- attr_accessor :bind_dn, :password
56
- attr_reader :connection, :uid, :base, :auth
57
- def self.validate(configuration={})
58
- message = []
59
- MUST_HAVE_KEYS.each do |name|
60
- message << name if configuration[name].nil?
61
- end
62
- raise ArgumentError.new(message.join(",") +" MUST be provided") unless message.empty?
63
- end
64
-
65
- def bind_as(args = {})
66
- result = false
67
- ldap = @connection
68
- ldap.auth args[:username], args[:password]
69
- rs = ldap.search(base: args[:base], filter: Net::LDAP::Filter.eq(@uid, args[:username].split('\\').last.to_s))
70
- result = rs.first if rs
71
- result
72
- end
73
-
74
- end
75
- end
76
-
77
- # Required for proper script name for suburis
78
- # Required for appending domain option to user credentials
79
- module Strategies
80
- class LDAP
81
- include OmniAuth::Strategy
82
-
83
- option :domain, ''
84
-
85
- def request_phase
86
- OmniAuth::LDAP::Adaptor.validate @options
87
- f = OmniAuth::Form.new( title: (options[:title] || "LDAP Authentication"), url: "#{@env['SCRIPT_NAME']}" + callback_path ) # Modified to include @env['SCRIPT_NAME']
88
- f.text_field 'Login', 'username'
89
- f.password_field 'Password', 'password'
90
- f.button "Sign In"
91
- f.to_response
92
- end
93
-
94
- def callback_phase
95
- bind_dn = "#{@options[:domain] + '\\' unless @options[:domain].blank?}#{request['username']}" # Added
96
- @options[:bind_dn] = bind_dn if @options[:bind_dn].blank? # Added
97
- @adaptor = OmniAuth::LDAP::Adaptor.new @options
98
- raise MissingCredentialsError.new("Missing login credentials") if request['username'].nil? || request['password'].nil?
99
- begin
100
- @ldap_user_info = @adaptor.bind_as(base: @adaptor.base, username: bind_dn, password: request['password']) # Modified
101
- return fail!(:invalid_credentials) if !@ldap_user_info
102
- @user_info = self.class.map_user(@@config, @ldap_user_info)
103
- super
104
- rescue Exception => e
105
- return fail!(:ldap_error, e)
106
- end
107
- end
108
- end
109
- end
110
- end
@@ -1,8 +0,0 @@
1
- require 'sass/rails'
2
-
3
- class Sass::Rails::Importer
4
- def sass_file? filename
5
- filename = filename.to_s
6
- SASS_EXTENSIONS.keys.any?{|ext| filename.match /#{ext}$/}
7
- end
8
- end
@@ -1,33 +0,0 @@
1
- require 'omniauth-openid'
2
- require 'omniauth-ldap'
3
- # require 'omniauth-twitter'
4
- # require 'omniauth-facebook'
5
- # require 'omniauth-linkedin'
6
- # require 'omniauth-cas'
7
-
8
- require 'openid/store/filesystem'
9
- Rails.application.config.middleware.use OmniAuth::Builder do
10
- provider :open_id, store: OpenID::Store::Filesystem.new('/tmp'), name: 'google_apps', identifier: 'https://www.google.com/accounts/o8/id'
11
- provider :open_id, store: OpenID::Store::Filesystem.new('/tmp')
12
- provider :LDAP, host: 'ldap.example.com', port: 389, method: :plain, base: 'cn=users,dc=example,dc=com', uid: 'sAMAccountName', domain: '' #, try_sasl: true, sasl_mechanisms: "GSS-SPNEGO"
13
-
14
- # provider :twitter, 'CONSUMER_KEY', 'CONSUMER_SECRET'
15
- # provider :facebook, 'APP_ID', 'APP_SECRET'
16
- # provider :linked_in, 'CONSUMER_KEY', 'CONSUMER_SECRET'
17
- # provider :cas, host: 'cas.yourdomain.com', login_url: 'https://www.example.com/cas'
18
-
19
- # Other providers will need gems added in your Gemfile, and the provider configured in this block.
20
- # https://github.com/intridea/omniauth/wiki/List-of-Strategies
21
- end
22
-
23
- # This list will show the first choice as the default, and the rest as potential secondary login methods.
24
- PROVIDERS = [:google_apps, :open_id, :LDAP, :twitter, :facebook, :linked_in, :cas]
25
-
26
- # LDAP
27
- # :port (required) - The LDAP server port.
28
- # :method (required) - May be :plain, :ssl, or :tls.
29
- # :base (required) - The distinguished name (DN) for your organization; all users should be searchable under this base.
30
- # :uid (required) - The LDAP attribute name for the user name in the login form. Typically AD would be 'sAMAccountName' or 'UniquePersonalIdentifier', while OpenLDAP is 'uid'. You can also use 'dn' for the user to put in the dn in the login form (but usually is too long for user to remember or know).
31
- # :domain - Enter to keep users from having to enter the LDAP domain, usually in the form domain\username. Backslash will be appended automatically.
32
- # :try_sasl - Try to use SASL connection to server.
33
- # :sasl_mechanisms - Mechanisms supported are 'DIGEST-MD5' and 'GSS-SPNEGO'
@@ -1,57 +0,0 @@
1
- require 'test_helper'
2
-
3
- SimpleCov.command_name "test:functionals"
4
-
5
- class Contour::AuthenticationsControllerTest < ActionController::TestCase
6
- setup do
7
- login(users(:valid))
8
- @request.env["omniauth.auth"] = {'provider' => 'google_apps', 'info'=> {'email' => 'test@example.com'}}
9
- @authentication = authentications(:open_id)
10
- end
11
-
12
- test "should get index" do
13
- get :index
14
- assert_response :success
15
- end
16
-
17
- # TODO: Remove
18
- # test "should get new" do
19
- # get :new
20
- # assert_response :success
21
- # end
22
-
23
- # TODO Redirects to Authentication Controller if user logged in, if not redirect to user sign up.
24
- test "should create authentication" do
25
- assert_difference('Authentication.count') do
26
- post :create, authentication: @authentication.attributes
27
- end
28
-
29
- assert_redirected_to authentications_path
30
- end
31
-
32
- # TODO: Remove
33
- # test "should show authentication" do
34
- # get :show, id: @authentication.to_param
35
- # assert_response :success
36
- # end
37
-
38
- # TODO: Remove
39
- # test "should get edit" do
40
- # get :edit, id: @authentication.to_param
41
- # assert_response :success
42
- # end
43
-
44
- # TODO: Remove
45
- # test "should update authentication" do
46
- # put :update, id: @authentication.to_param, authentication: @authentication.attributes
47
- # assert_redirected_to authentication_path(assigns(:authentication))
48
- # end
49
-
50
- test "should destroy authentication" do
51
- assert_difference('Authentication.count', -1) do
52
- delete :destroy, id: @authentication, format: 'js'
53
- end
54
-
55
- assert_template 'destroy'
56
- end
57
- end
@@ -1,33 +0,0 @@
1
- require 'omniauth-openid'
2
- require 'omniauth-ldap'
3
- # require 'omniauth-twitter'
4
- # require 'omniauth-facebook'
5
- # require 'omniauth-linkedin'
6
- # require 'omniauth-cas'
7
-
8
- require 'openid/store/filesystem'
9
- Rails.application.config.middleware.use OmniAuth::Builder do
10
- provider :open_id, store: OpenID::Store::Filesystem.new('/tmp'), name: 'google_apps', identifier: 'https://www.google.com/accounts/o8/id'
11
- provider :open_id, store: OpenID::Store::Filesystem.new('/tmp')
12
- provider :LDAP, host: 'ldap.example.com', port: 389, method: :plain, base: 'cn=users,dc=example,dc=com', uid: 'sAMAccountName', domain: '' #, try_sasl: true, sasl_mechanisms: "GSS-SPNEGO"
13
-
14
- # provider :twitter, 'CONSUMER_KEY', 'CONSUMER_SECRET'
15
- # provider :facebook, 'APP_ID', 'APP_SECRET'
16
- # provider :linked_in, 'CONSUMER_KEY', 'CONSUMER_SECRET'
17
- # provider :cas, host: 'cas.yourdomain.com', login_url: 'https://www.example.com/cas'
18
-
19
- # Other providers will need gems added in your Gemfile, and the provider configured in this block.
20
- # https://github.com/intridea/omniauth/wiki/List-of-Strategies
21
- end
22
-
23
- # This list will show the first choice as the default, and the rest as potential secondary login methods.
24
- PROVIDERS = [:google_apps, :open_id, :LDAP, :twitter, :facebook, :linked_in, :cas]
25
-
26
- # LDAP
27
- # :port (required) - The LDAP server port.
28
- # :method (required) - May be :plain, :ssl, or :tls.
29
- # :base (required) - The distinguished name (DN) for your organization; all users should be searchable under this base.
30
- # :uid (required) - The LDAP attribute name for the user name in the login form. Typically AD would be 'sAMAccountName' or 'UniquePersonalIdentifier', while OpenLDAP is 'uid'. You can also use 'dn' for the user to put in the dn in the login form (but usually is too long for user to remember or know).
31
- # :domain - Enter to keep users from having to enter the LDAP domain, usually in the form domain\username. Backslash will be appended automatically.
32
- # :try_sasl - Try to use SASL connection to server.
33
- # :sasl_mechanisms - Mechanisms supported are 'DIGEST-MD5' and 'GSS-SPNEGO'
@@ -1,11 +0,0 @@
1
- class CreateAuthentications < ActiveRecord::Migration
2
- def change
3
- create_table :authentications do |t|
4
- t.integer :user_id
5
- t.string :provider
6
- t.string :uid
7
-
8
- t.timestamps
9
- end
10
- end
11
- end
@@ -1,16 +0,0 @@
1
- # Read about fixtures at http://ar.rubyonrails.org/classes/Fixtures.html
2
-
3
- open_id:
4
- user: valid
5
- provider: open_id
6
- uid: open_id@open_id.com
7
-
8
- google_apps:
9
- user: valid
10
- provider: google_apps
11
- uid: test@gmail.com
12
-
13
- ldap:
14
- user: valid
15
- provider: ldap
16
- uid: "CN=ldapid,CN=Users,DC=example,DC=com"
@@ -1,11 +0,0 @@
1
- require 'test_helper'
2
-
3
- class AuthenticationTest < ActiveSupport::TestCase
4
- test "should get provider name and handle OpenID special case" do
5
- assert_equal 'OpenID', authentications(:open_id).provider_name
6
- end
7
-
8
- test "should get provider name" do
9
- assert_equal 'Google Apps', authentications(:google_apps).provider_name
10
- end
11
- end