Skip to content

Commit

Permalink
moved the username builder into an --advanced switch, since most peop…
Browse files Browse the repository at this point in the history
…le won't need it by default
  • Loading branch information
dpmcnevin committed Aug 14, 2010
1 parent ff3d9b6 commit af6e5eb
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
21 changes: 12 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ This will *only* work for Rails 3 applications.
In the Gemfile for your application:

gem "devise", "1.1.1"
gem "devise_ldap_authenticatable", "0.4.3"
gem "devise_ldap_authenticatable", "0.4.4"

To get the latest version, pull directly from github instead of the gem:

Expand All @@ -44,17 +44,18 @@ Setup

Run the rails generator

rails generate devise_ldap_authenticatable:install
rails generate devise_ldap_authenticatable:install [options]

This will install the sample.yml, update the devise.rb initializer, and update your user model. There are some options you can pass to it:

[--user-model=USER_MODEL] # Model to update
# Default: user
[--update-model] # Update model to change from database_authenticatable to ldap_authenticatable
# Default: true
[--add-rescue] # Update Application Controller with resuce_from for DeviseLdapAuthenticatable::LdapException
# Default: true

Options:
[--user-model=USER_MODEL] # Model to update
# Default: user
[--update-model] # Update model to change from database_authenticatable to ldap_authenticatable
# Default: true
[--add-rescue] # Update Application Controller with resuce_from for DeviseLdapAuthenticatable::LdapException
# Default: true
[--advanced] # Add advanced config options to the devise initializer


Usage
Expand Down Expand Up @@ -100,6 +101,8 @@ In initializer `config/initializers/devise.rb` :
Advanced Configuration
----------------------

These parameters will be added to `config/initializers/devise.rb` when you pass the `--advanced` switch to the generator:

* ldap\_auth\_username\_builder _(default: `Proc.new() {|attribute, login, ldap| "#{attribute}=#{login},#{ldap.base}" }`)_
* You can pass a proc to the username option to explicitly specify the format that you search for a users' DN on your LDAP server.

Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.4.3
0.4.4
2 changes: 1 addition & 1 deletion lib/devise_ldap_authenticatable/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module DeviseLdapAuthenticatable
VERSION = "0.4.3"
VERSION = "0.4.4"
end

11 changes: 9 additions & 2 deletions lib/generators/devise_ldap_authenticatable/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class InstallGenerator < Rails::Generators::Base
class_option :user_model, :type => :string, :default => "user", :desc => "Model to update"
class_option :update_model, :type => :boolean, :default => true, :desc => "Update model to change from database_authenticatable to ldap_authenticatable"
class_option :add_rescue, :type => :boolean, :default => true, :desc => "Update Application Controller with resuce_from for DeviseLdapAuthenticatable::LdapException"
class_option :advanced, :type => :boolean, :desc => "Add advanced config options to the devise initializer"


def create_ldap_config
Expand All @@ -26,7 +27,7 @@ def update_application_controller
private

def default_devise_settings
<<-eof
settings = <<-eof
# ==> LDAP Configuration
# config.ldap_logger = true
# config.ldap_create_user = false
Expand All @@ -36,10 +37,16 @@ def default_devise_settings
# config.ldap_check_attributes = false
# config.ldap_use_admin_to_bind = false
eof
if options.advanced?
settings << <<-eof
# ==> Advanced LDAP Configuration
# config.ldap_auth_username_builder = Proc.new() {|attribute, login, ldap| "\#{attribute}=\#{login},\#{ldap.base}" }
eof
eof
end

settings
end

def rescue_from_exception
Expand Down

0 comments on commit af6e5eb

Please sign in to comment.