Easy to use Active Directory Authentication for Rails.
Add the Adauth gem to your Gemfile:
gem 'adauth'
and run a bundle install
First off create a new config file by running the config generator
rails g adauth:config
Fill out the config values in config/initializers/adauth.rb
If you want to link your user model to Adauth you can use this simple code:
class User < ActiveRecord::Base
include Adauth::Rails::ModelBridge
AdauthMappings = {
:login => :login
:group_strings => :cn_groups
}
AdauthSearchField = [:login, :login]
end
This gives you a bridge between Adauth and your model. When you call User.create_from_adauth(adauth_model)
it does:
u = User.new
u.login = adauth_model.login
u.group_strings = adauth_model.cn_groups
u.save
This can be used for any model and anything that you pull over through adauth.
You can use a premade sessions controller by running
rails g adauth:sessions
Which adds a couple of routes, a sessions controller and a login form. To login go to /sessions/new and fill out the form, you will then POST to /adauth and if succesful you will be sent back to root_path
To use Adauth in a script or other program just call Adauth.configure
somewhere at the begining of the script, once configured Adauth can be used anywhere in your program the same as rails.
Adauth has a few configuration options which are described in detail on the wiki.
Adauth logs to weekly logs in logs/adauth.log(.DATE)
You can interact with the logger through Adauth.logger
and set a new one using Adauth.logger=
Before you can run the tests you will need to write a yml file with your domain settings in and place it at spec/test_data.yml, there is an example of this file in the spec folder.
When you fork Adauth please:
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request