
Security News
Rspack Introduces Rslint, a TypeScript-First Linter Written in Go
Rspack launches Rslint, a fast TypeScript-first linter built on typescript-go, joining in on the trend of toolchains creating their own linters.
houston-devise_ldap_authenticatable
Advanced tools
Devise LDAP Authenticatable is a LDAP based authentication strategy for the Devise authentication framework.
If you are building applications for use within your organization which require authentication and you want to use LDAP, this plugin is for you.
Devise LDAP Authenticatable works in replacement of Database Authenticatable. This devise plugin has not been tested with DatabaseAuthenticatable enabled at the same time. This is meant as a drop in replacement for DatabaseAuthenticatable allowing for a semi single sign on approach.
For a screencast with an example application, please visit: http://random-rails.blogspot.com/2010/07/ldap-authentication-with-devise.html
In the Gemfile for your application:
gem "devise_ldap_authenticatable"
To get the latest version, pull directly from github instead of the gem:
gem "devise_ldap_authenticatable", :git => "git://github.com/cschiewek/devise_ldap_authenticatable.git"
Run the rails generators for devise (please check the devise documents for further instructions)
rails generate devise:install
rails generate devise MODEL_NAME
Run the rails generator for devise_ldap_authenticatable
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:
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 rescue_from for DeviseLdapAuthenticatable::LdapException
# Default: true
[--advanced] # Add advanced config options to the devise initializer
Given that ldap_create_user
is set to true and you are authenticating with username, you can query an LDAP server for other attributes.
in your user model:
before_save :get_ldap_email
def get_ldap_email
self.email = Devise::LdapAdapter.get_ldap_param(self.username,"mail")
end
In initializer config/initializers/devise.rb
:
ldap_logger
(default: true)
ldap_create_user
(default: false)
ldap_config
(default: #{Rails.root}/config/ldap.yml)
ldap_update_password
(default: true)
ldap_check_group_membership
(default: false)
ldap_check_attributes
(default: false)
ldap_use_admin_to_bind
(default: false)
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}" }
)
Using a "username" instead of an "email": The field that is used for logins is the first key that's configured in the config/devise.rb
file under config.authentication_keys
, which by default is email. For help changing this, please see the Railscast that goes through how to customize Devise.
SSL certificate invalid: If you're using a test LDAP server running a self-signed SSL certificate, make sure the appropriate root certificate is installed on your system. Alternately, you may temporarily disable certificate checking for SSL by modifying your system LDAP configuration (e.g., /etc/openldap/ldap.conf
or /etc/ldap/ldap.conf
) to read TLS_REQCERT never
.
To contribute to devise_ldap_authentication
, you should be able to run a test OpenLDAP server. Specifically, you need the slapd
, ldapadd
, and ldapmodify
binaries.
This seems to come out of the box with Mac OS X 10.6.
On Ubuntu (tested on 12.04 and 12.10), you can run sudo apt-get install slapd ldap-utils
. You will also likely have to add the spec/ldap
directory of your local git clone to the slapd apparmor profile /etc/apparmor.d/usr.sbin.slapd
if you get permissions errors. Something like this should do:
/path/to/devise_ldap_authenticatable/spec/ldap/** rw,$
To start hacking on devise_ldap_authentication
, clone the github repository, start the test LDAP server, and run the rake test task:
git clone https://github.com/cschiewek/devise_ldap_authenticatable.git
cd devise_ldap_authenticatable
bundle install
# in a separate console or backgrounded
./spec/ldap/run-server
bundle exec rake db:migrate # first time only
bundle exec rake spec
Released under the MIT license
Copyright (c) 2012 Curtis Schiewek, Daniel McNevin, Steven Xu
FAQs
Unknown package
We found that houston-devise_ldap_authenticatable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Rspack launches Rslint, a fast TypeScript-first linter built on typescript-go, joining in on the trend of toolchains creating their own linters.
Security News
Hacker Demonstrates How Easy It Is To Steal Data From Popular Password Managers
Security News
Oxlint’s new preview brings type-aware linting powered by typescript-go, combining advanced TypeScript rules with native-speed performance.