devise_ldap_authenticatable 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/.gitignore +5 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +4 -1
  4. data/Rakefile +52 -0
  5. data/VERSION +1 -0
  6. data/devise_ldap_authenticatable.gemspec +166 -0
  7. data/lib/devise_ldap_authenticatable.rb +3 -0
  8. data/lib/devise_ldap_authenticatable/ldap_adapter.rb +14 -4
  9. data/lib/devise_ldap_authenticatable/model.rb +26 -26
  10. data/lib/devise_ldap_authenticatable/version.rb +1 -1
  11. data/lib/generators/devise_ldap_authenticatable/install_generator.rb +2 -0
  12. data/rails/init.rb +2 -0
  13. data/test/devise_ldap_authenticatable_test.rb +8 -0
  14. data/test/ldap/base.ldif +54 -0
  15. data/test/ldap/clear.ldif +20 -0
  16. data/test/ldap/local.schema +6 -0
  17. data/test/ldap/run-server.sh +4 -0
  18. data/test/ldap/slapd-test.conf +106 -0
  19. data/test/rails_app/Gemfile +22 -0
  20. data/test/rails_app/Rakefile +7 -0
  21. data/test/rails_app/app/controllers/application_controller.rb +4 -0
  22. data/test/rails_app/app/controllers/posts_controller.rb +15 -0
  23. data/test/rails_app/app/helpers/application_helper.rb +2 -0
  24. data/test/rails_app/app/helpers/posts_helper.rb +2 -0
  25. data/test/rails_app/app/models/post.rb +2 -0
  26. data/test/rails_app/app/models/user.rb +10 -0
  27. data/test/rails_app/app/views/layouts/application.html.erb +26 -0
  28. data/test/rails_app/app/views/posts/index.html.erb +2 -0
  29. data/test/rails_app/config.ru +4 -0
  30. data/test/rails_app/config/application.rb +46 -0
  31. data/test/rails_app/config/boot.rb +13 -0
  32. data/test/rails_app/config/cucumber.yml +8 -0
  33. data/test/rails_app/config/database.yml +25 -0
  34. data/test/rails_app/config/environment.rb +5 -0
  35. data/test/rails_app/config/environments/development.rb +22 -0
  36. data/test/rails_app/config/environments/production.rb +46 -0
  37. data/test/rails_app/config/environments/test.rb +34 -0
  38. data/test/rails_app/config/initializers/backtrace_silencers.rb +7 -0
  39. data/test/rails_app/config/initializers/devise.rb +140 -0
  40. data/test/rails_app/config/initializers/inflections.rb +10 -0
  41. data/test/rails_app/config/initializers/mime_types.rb +5 -0
  42. data/test/rails_app/config/initializers/secret_token.rb +7 -0
  43. data/test/rails_app/config/initializers/session_store.rb +8 -0
  44. data/test/rails_app/config/ldap.yml +33 -0
  45. data/test/rails_app/config/ldap_with_uid.yml +30 -0
  46. data/test/rails_app/config/locales/devise.en.yml +39 -0
  47. data/test/rails_app/config/locales/en.yml +5 -0
  48. data/test/rails_app/config/routes.rb +64 -0
  49. data/test/rails_app/db/migrate/20100708120302_create_posts.rb +14 -0
  50. data/test/rails_app/db/migrate/20100708120448_devise_create_users.rb +26 -0
  51. data/test/rails_app/db/schema.rb +41 -0
  52. data/test/rails_app/db/seeds.rb +7 -0
  53. data/test/rails_app/features/manage_logins.feature +34 -0
  54. data/test/rails_app/features/step_definitions/login_steps.rb +16 -0
  55. data/test/rails_app/features/step_definitions/web_steps.rb +219 -0
  56. data/test/rails_app/features/support/env.rb +58 -0
  57. data/test/rails_app/features/support/paths.rb +38 -0
  58. data/test/rails_app/lib/tasks/.gitkeep +0 -0
  59. data/test/rails_app/lib/tasks/cucumber.rake +53 -0
  60. data/test/rails_app/public/404.html +26 -0
  61. data/test/rails_app/public/422.html +26 -0
  62. data/test/rails_app/public/500.html +26 -0
  63. data/test/rails_app/public/images/rails.png +0 -0
  64. data/test/rails_app/public/javascripts/application.js +2 -0
  65. data/test/rails_app/public/javascripts/controls.js +965 -0
  66. data/test/rails_app/public/javascripts/dragdrop.js +974 -0
  67. data/test/rails_app/public/javascripts/effects.js +1123 -0
  68. data/test/rails_app/public/javascripts/prototype.js +4874 -0
  69. data/test/rails_app/public/javascripts/rails.js +118 -0
  70. data/test/rails_app/public/stylesheets/.gitkeep +0 -0
  71. data/test/rails_app/script/cucumber +10 -0
  72. data/test/rails_app/script/rails +6 -0
  73. data/test/rails_app/test/factories/users.rb +9 -0
  74. data/test/rails_app/test/functional/posts_controller_test.rb +58 -0
  75. data/test/rails_app/test/performance/browsing_test.rb +9 -0
  76. data/test/rails_app/test/test_helper.rb +22 -0
  77. data/test/rails_app/test/unit/helpers/posts_helper_test.rb +4 -0
  78. data/test/rails_app/test/unit/post_test.rb +8 -0
  79. data/test/rails_app/test/unit/user_test.rb +172 -0
  80. data/test/test_helper.rb +3 -0
  81. metadata +140 -30
@@ -0,0 +1,46 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The production environment is meant for finished, "live" apps.
5
+ # Code is not reloaded between requests
6
+ config.cache_classes = true
7
+
8
+ # Full error reports are disabled and caching is turned on
9
+ config.consider_all_requests_local = false
10
+ config.action_controller.perform_caching = true
11
+
12
+ # Specifies the header that your server uses for sending files
13
+ config.action_dispatch.x_sendfile_header = "X-Sendfile"
14
+
15
+ # For nginx:
16
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect'
17
+
18
+ # If you have no front-end server that supports something like X-Sendfile,
19
+ # just comment this out and Rails will serve the files
20
+
21
+ # See everything in the log (default is :info)
22
+ # config.log_level = :debug
23
+
24
+ # Use a different logger for distributed setups
25
+ # config.logger = SyslogLogger.new
26
+
27
+ # Use a different cache store in production
28
+ # config.cache_store = :mem_cache_store
29
+
30
+ # Disable Rails's static asset server
31
+ # In production, Apache or nginx will already do this
32
+ config.serve_static_assets = false
33
+
34
+ # Enable serving of images, stylesheets, and javascripts from an asset server
35
+ # config.action_controller.asset_host = "http://assets.example.com"
36
+
37
+ # Disable delivery errors, bad email addresses will be ignored
38
+ # config.action_mailer.raise_delivery_errors = false
39
+
40
+ # Enable threaded mode
41
+ # config.threadsafe!
42
+
43
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
44
+ # the I18n.default_locale when a translation can not be found)
45
+ config.i18n.fallbacks = true
46
+ end
@@ -0,0 +1,34 @@
1
+ RailsApp::Application.configure do
2
+ # Settings specified here will take precedence over those in config/environment.rb
3
+
4
+ # The test environment is used exclusively to run your application's
5
+ # test suite. You never need to work with it otherwise. Remember that
6
+ # your test database is "scratch space" for the test suite and is wiped
7
+ # and recreated between test runs. Don't rely on the data there!
8
+ config.cache_classes = true
9
+
10
+ # Log error messages when you accidentally call methods on nil.
11
+ config.whiny_nils = true
12
+
13
+ # Show full error reports and disable caching
14
+ config.consider_all_requests_local = true
15
+ config.action_controller.perform_caching = false
16
+
17
+ # Raise exceptions instead of rendering exception templates
18
+ config.action_dispatch.show_exceptions = false
19
+
20
+ # Disable request forgery protection in test environment
21
+ config.action_controller.allow_forgery_protection = false
22
+
23
+ # Tell Action Mailer not to deliver emails to the real world.
24
+ # The :test delivery method accumulates sent emails in the
25
+ # ActionMailer::Base.deliveries array.
26
+ config.action_mailer.delivery_method = :test
27
+
28
+ config.active_support.deprecation = :stderr
29
+
30
+ # Use SQL instead of Active Record's schema dumper when creating the test database.
31
+ # This is necessary if your schema can't be completely dumped by the schema dumper,
32
+ # like if you have constraints or database-specific column types
33
+ # config.active_record.schema_format = :sql
34
+ end
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
4
+ # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
5
+
6
+ # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
7
+ # Rails.backtrace_cleaner.remove_silencers!
@@ -0,0 +1,140 @@
1
+ # Use this hook to configure devise mailer, warden hooks and so forth. The first
2
+ # four configuration values can also be set straight in your models.
3
+ Devise.setup do |config|
4
+ # ==> LDAP Configuration
5
+ # config.ldap_create_user = true
6
+ # config.ldap_update_password = true
7
+ # config.ldap_config = "#{Rails.root}/config/ldap.yml"
8
+
9
+ # ==> Mailer Configuration
10
+ # Configure the e-mail address which will be shown in DeviseMailer.
11
+ config.mailer_sender = "please-change-me@config-initializers-devise.com"
12
+
13
+ # Configure the class responsible to send e-mails.
14
+ # config.mailer = "Devise::Mailer"
15
+
16
+ # ==> ORM configuration
17
+ # Load and configure the ORM. Supports :active_record (default), :mongoid
18
+ # (bson_ext recommended) and :data_mapper (experimental).
19
+ require 'devise/orm/active_record'
20
+
21
+ # ==> Configuration for any authentication mechanism
22
+ # Configure which keys are used when authenticating an user. By default is
23
+ # just :email. You can configure it to use [:username, :subdomain], so for
24
+ # authenticating an user, both parameters are required. Remember that those
25
+ # parameters are used only when authenticating and not when retrieving from
26
+ # session. If you need permissions, you should implement that in a before filter.
27
+ # config.authentication_keys = [ :email ]
28
+
29
+ # Tell if authentication through request.params is enabled. True by default.
30
+ # config.params_authenticatable = true
31
+
32
+ # Tell if authentication through HTTP Basic Auth is enabled. True by default.
33
+ # config.http_authenticatable = true
34
+
35
+ # The realm used in Http Basic Authentication
36
+ # config.http_authentication_realm = "Application"
37
+
38
+ # ==> Configuration for :database_authenticatable
39
+ # For bcrypt, this is the cost for hashing the password and defaults to 10. If
40
+ # using other encryptors, it sets how many times you want the password re-encrypted.
41
+ config.stretches = 10
42
+
43
+ # Define which will be the encryption algorithm. Devise also supports encryptors
44
+ # from others authentication tools as :clearance_sha1, :authlogic_sha512 (then
45
+ # you should set stretches above to 20 for default behavior) and :restful_authentication_sha1
46
+ # (then you should set stretches to 10, and copy REST_AUTH_SITE_KEY to pepper)
47
+ config.encryptor = :bcrypt
48
+
49
+ # Setup a pepper to generate the encrypted password.
50
+ config.pepper = "b4a6e95e4483fa2a883fe02228ad167051c967dd78f8adf3c924496d4a602ad92fe58c9b58b954487d32828e4540cd562f2f69618733265dd6a824973389598f"
51
+
52
+ # ==> Configuration for :confirmable
53
+ # The time you want to give your user to confirm his account. During this time
54
+ # he will be able to access your application without confirming. Default is nil.
55
+ # When confirm_within is zero, the user won't be able to sign in without confirming.
56
+ # You can use this to let your user access some features of your application
57
+ # without confirming the account, but blocking it after a certain period
58
+ # (ie 2 days).
59
+ # config.confirm_within = 2.days
60
+
61
+ # ==> Configuration for :rememberable
62
+ # The time the user will be remembered without asking for credentials again.
63
+ # config.remember_for = 2.weeks
64
+
65
+ # ==> Configuration for :validatable
66
+ # Range for password length
67
+ # config.password_length = 6..20
68
+
69
+ # Regex to use to validate the email address
70
+ # config.email_regexp = /^([\w\.%\+\-]+)@([\w\-]+\.)+([\w]{2,})$/i
71
+
72
+ # ==> Configuration for :timeoutable
73
+ # The time you want to timeout the user session without activity. After this
74
+ # time the user will be asked for credentials again.
75
+ # config.timeout_in = 10.minutes
76
+
77
+ # ==> Configuration for :lockable
78
+ # Defines which strategy will be used to lock an account.
79
+ # :failed_attempts = Locks an account after a number of failed attempts to sign in.
80
+ # :none = No lock strategy. You should handle locking by yourself.
81
+ # config.lock_strategy = :failed_attempts
82
+
83
+ # Defines which strategy will be used to unlock an account.
84
+ # :email = Sends an unlock link to the user email
85
+ # :time = Re-enables login after a certain amount of time (see :unlock_in below)
86
+ # :both = Enables both strategies
87
+ # :none = No unlock strategy. You should handle unlocking by yourself.
88
+ # config.unlock_strategy = :both
89
+
90
+ # Number of authentication tries before locking an account if lock_strategy
91
+ # is failed attempts.
92
+ # config.maximum_attempts = 20
93
+
94
+ # Time interval to unlock the account if :time is enabled as unlock_strategy.
95
+ # config.unlock_in = 1.hour
96
+
97
+ # ==> Configuration for :token_authenticatable
98
+ # Defines name of the authentication token params key
99
+ # config.token_authentication_key = :auth_token
100
+
101
+ # ==> Scopes configuration
102
+ # Turn scoped views on. Before rendering "sessions/new", it will first check for
103
+ # "sessions/users/new". It's turned off by default because it's slower if you
104
+ # are using only default views.
105
+ # config.scoped_views = true
106
+
107
+ # By default, devise detects the role accessed based on the url. So whenever
108
+ # accessing "/users/sign_in", it knows you are accessing an User. This makes
109
+ # routes as "/sign_in" not possible, unless you tell Devise to use the default
110
+ # scope, setting true below.
111
+ # Note that devise does not generate default routes. You also have to
112
+ # specify them in config/routes.rb
113
+ # config.use_default_scope = true
114
+
115
+ # Configure the default scope used by Devise. By default it's the first devise
116
+ # role declared in your routes.
117
+ # config.default_scope = :user
118
+
119
+ # ==> Navigation configuration
120
+ # Lists the formats that should be treated as navigational. Formats like
121
+ # :html, should redirect to the sign in page when the user does not have
122
+ # access, but formats like :xml or :json, should return 401.
123
+ # If you have any extra navigational formats, like :iphone or :mobile, you
124
+ # should add them to the navigational formats lists. Default is [:html]
125
+ # config.navigational_formats = [:html, :iphone]
126
+
127
+ # ==> Warden configuration
128
+ # If you want to use other strategies, that are not (yet) supported by Devise,
129
+ # you can configure them inside the config.warden block. The example below
130
+ # allows you to setup OAuth, using http://github.com/roman/warden_oauth
131
+ #
132
+ # config.warden do |manager|
133
+ # manager.oauth(:twitter) do |twitter|
134
+ # twitter.consumer_secret = <YOUR CONSUMER SECRET>
135
+ # twitter.consumer_key = <YOUR CONSUMER KEY>
136
+ # twitter.options :site => 'http://twitter.com'
137
+ # end
138
+ # manager.default_strategies(:scope => :user).unshift :twitter_oauth
139
+ # end
140
+ end
@@ -0,0 +1,10 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new inflection rules using the following format
4
+ # (all these examples are active by default):
5
+ # ActiveSupport::Inflector.inflections do |inflect|
6
+ # inflect.plural /^(ox)$/i, '\1en'
7
+ # inflect.singular /^(ox)en/i, '\1'
8
+ # inflect.irregular 'person', 'people'
9
+ # inflect.uncountable %w( fish sheep )
10
+ # end
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Rails.application.config.secret_token = '91f200017212d5529ed7dea1959a9bb36b937bdbddab9180114119a36dd9283c7f8c8d22cd299ce6c6f40e6b8121972953658ef357991b4716b7749a9b215402'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Rails.application.config.session_store :cookie_store, :key => '_rails_app_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rake db:sessions:create")
8
+ # Rails.application.config.session_store :active_record_store
@@ -0,0 +1,33 @@
1
+ ## Build / start instructions for LDAP
2
+
3
+ # cd test/ldap
4
+ # mkdir openldap-data
5
+ # mkdir openldap-data/run
6
+ # ./run-server.sh &
7
+ # ldapadd -h localhost -p 3389 -x -D "cn=admin,dc=test,dc=com" -w secret -f base.ldif
8
+ #
9
+ # this creates the users:
10
+ # cn=admin,dc=test,com / secret
11
+ # cn=example.user@test.com,ou=people,dc=test,dc=com / secret
12
+
13
+ authorizations: &AUTHORIZATIONS
14
+ ## Authorization
15
+ group_base: ou=groups,dc=test,dc=com
16
+ required_groups:
17
+ - cn=admins,ou=groups,dc=test,dc=com
18
+ require_attribute:
19
+ objectClass: inetOrgPerson
20
+ authorizationRole: blogAdmin
21
+
22
+ test: &TEST
23
+ host: localhost
24
+ port: 3389
25
+ attribute: cn
26
+ base: ou=people,dc=test,dc=com
27
+ admin_user: cn=admin,dc=test,dc=com
28
+ admin_password: secret
29
+ ssl: false
30
+ <<: *AUTHORIZATIONS
31
+
32
+ development:
33
+ <<: *TEST
@@ -0,0 +1,30 @@
1
+ ## Build / start instructions for LDAP
2
+
3
+ # cd test/ldap
4
+ # mkdir openldap-data
5
+ # mkdir openldap-data/run
6
+ # ./run-server.sh &
7
+ # ldapadd -h localhost -p 3389 -x -D "cn=admin,dc=test,dc=com" -w secret -f base.ldif
8
+ #
9
+ # this creates the users:
10
+ # cn=admin,dc=test,com / secret
11
+ # cn=example.user@test.com,ou=people,dc=test,dc=com / secret
12
+
13
+ authorizations: &AUTHORIZATIONS
14
+ ## Authorization
15
+ group_base: ou=groups,dc=test,dc=com
16
+ required_groups:
17
+ - cn=admins,ou=groups,dc=test,dc=com
18
+ require_attribute:
19
+ objectClass: inetOrgPerson
20
+ authorizationRole: blogAdmin
21
+
22
+ test:
23
+ host: localhost
24
+ port: 3389
25
+ attribute: uid
26
+ base: ou=people,dc=test,dc=com
27
+ admin_user: cn=admin,dc=test,dc=com
28
+ admin_password: secret
29
+ ssl: false
30
+ <<: *AUTHORIZATIONS
@@ -0,0 +1,39 @@
1
+ en:
2
+ errors:
3
+ messages:
4
+ not_found: "not found"
5
+ already_confirmed: "was already confirmed"
6
+ not_locked: "was not locked"
7
+
8
+ devise:
9
+ failure:
10
+ unauthenticated: 'You need to sign in or sign up before continuing.'
11
+ unconfirmed: 'You have to confirm your account before continuing.'
12
+ locked: 'Your account is locked.'
13
+ invalid: 'Invalid email or password.'
14
+ invalid_token: 'Invalid authentication token.'
15
+ timeout: 'Your session expired, please sign in again to continue.'
16
+ inactive: 'Your account was not activated yet.'
17
+ sessions:
18
+ signed_in: 'Signed in successfully.'
19
+ signed_out: 'Signed out successfully.'
20
+ passwords:
21
+ send_instructions: 'You will receive an email with instructions about how to reset your password in a few minutes.'
22
+ updated: 'Your password was changed successfully. You are now signed in.'
23
+ confirmations:
24
+ send_instructions: 'You will receive an email with instructions about how to confirm your account in a few minutes.'
25
+ confirmed: 'Your account was successfully confirmed. You are now signed in.'
26
+ registrations:
27
+ signed_up: 'You have signed up successfully. If enabled, a confirmation was sent to your e-mail.'
28
+ updated: 'You updated your account successfully.'
29
+ destroyed: 'Bye! Your account was successfully cancelled. We hope to see you again soon.'
30
+ unlocks:
31
+ send_instructions: 'You will receive an email with instructions about how to unlock your account in a few minutes.'
32
+ unlocked: 'Your account was successfully unlocked. You are now signed in.'
33
+ mailer:
34
+ confirmation_instructions:
35
+ subject: 'Confirmation instructions'
36
+ reset_password_instructions:
37
+ subject: 'Reset password instructions'
38
+ unlock_instructions:
39
+ subject: 'Unlock Instructions'
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See http://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,64 @@
1
+ RailsApp::Application.routes.draw do
2
+ devise_for :users
3
+
4
+ resources :posts
5
+
6
+ root :to => "posts#index"
7
+
8
+ # The priority is based upon order of creation:
9
+ # first created -> highest priority.
10
+
11
+ # Sample of regular route:
12
+ # match 'products/:id' => 'catalog#view'
13
+ # Keep in mind you can assign values other than :controller and :action
14
+
15
+ # Sample of named route:
16
+ # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase
17
+ # This route can be invoked with purchase_url(:id => product.id)
18
+
19
+ # Sample resource route (maps HTTP verbs to controller actions automatically):
20
+ # resources :products
21
+
22
+ # Sample resource route with options:
23
+ # resources :products do
24
+ # member do
25
+ # get :short
26
+ # post :toggle
27
+ # end
28
+ #
29
+ # collection do
30
+ # get :sold
31
+ # end
32
+ # end
33
+
34
+ # Sample resource route with sub-resources:
35
+ # resources :products do
36
+ # resources :comments, :sales
37
+ # resource :seller
38
+ # end
39
+
40
+ # Sample resource route with more complex sub-resources
41
+ # resources :products do
42
+ # resources :comments
43
+ # resources :sales do
44
+ # get :recent, :on => :collection
45
+ # end
46
+ # end
47
+
48
+ # Sample resource route within a namespace:
49
+ # namespace :admin do
50
+ # # Directs /admin/products/* to Admin::ProductsController
51
+ # # (app/controllers/admin/products_controller.rb)
52
+ # resources :products
53
+ # end
54
+
55
+ # You can have the root of your site routed with "root"
56
+ # just remember to delete public/index.html.
57
+ # root :to => "welcome#index"
58
+
59
+ # See how all your routes lay out with "rake routes"
60
+
61
+ # This is a legacy wild controller route that's not recommended for RESTful applications.
62
+ # Note: This route will make all actions in every controller accessible via GET requests.
63
+ # match ':controller(/:action(/:id(.:format)))'
64
+ end