2013-04-21 00:26:36 -04:00
|
|
|
#devise-kerberos-authenticatable
|
|
|
|
|
|
|
|
##Description
|
|
|
|
|
|
|
|
devise-kerberos-authenticatable is a Devise exenstion that can be used to authenticate against Kerberos as setup in your local krb5.conf file.
|
|
|
|
|
|
|
|
##Installation
|
|
|
|
|
|
|
|
###Dependencies
|
|
|
|
[timfel-krb5-auth](https://github.com/timfel/krb5-auth) depends on the headers and development libraries for MIT Kerberos.
|
2013-04-21 00:29:57 -04:00
|
|
|
|
2013-04-21 00:26:36 -04:00
|
|
|
```sudo apt-get install libkrb5-dev```
|
|
|
|
###Server Setup
|
|
|
|
Modify your /etc/krb5.conf file as necessary to authenticate against your Kerberos server.
|
|
|
|
|
|
|
|
###Rails Setup
|
2013-04-21 00:37:50 -04:00
|
|
|
* Update your gemfile
|
|
|
|
|
|
|
|
```gem 'devise-kerberos-authenticatable', :git => 'git://github.com/atomaka/devise-kerberos-authenticatable.git'```
|
2013-04-21 00:29:57 -04:00
|
|
|
|
2014-01-31 07:52:59 -05:00
|
|
|
* Create a migration to add username field to user table
|
|
|
|
|
|
|
|
```
|
|
|
|
class AddUsernameToUser < ActiveRecord::Migration
|
|
|
|
def change
|
|
|
|
add_column :users, :username, :string
|
|
|
|
end
|
|
|
|
end
|
|
|
|
```
|
|
|
|
|
|
|
|
* Create a migration to remove the index on email from the user table
|
|
|
|
|
|
|
|
```
|
|
|
|
class RemoveIndexOnEmailFromUsers < ActiveRecord::Migration
|
|
|
|
def up
|
|
|
|
remove_index :users, 'email'
|
|
|
|
end
|
|
|
|
|
|
|
|
def down
|
|
|
|
add_index :users, :email, :unique => true
|
|
|
|
end
|
|
|
|
end
|
|
|
|
```
|
|
|
|
* Migrate the databse
|
|
|
|
|
|
|
|
```
|
|
|
|
rake db:migrate
|
|
|
|
```
|
|
|
|
|
|
|
|
* Edit config/initializers/devise.rb to use a username instead of email for login and add a kerberos realm to use.
|
|
|
|
|
|
|
|
```
|
|
|
|
config.authentication_keys = [ :username ]
|
|
|
|
config.kerberos_realm = "EXAMPLE.REALM"
|
|
|
|
```
|
|
|
|
|
|
|
|
|
2013-04-21 00:26:36 -04:00
|
|
|
* Update your Devise model app/models/user.rb
|
2013-04-21 00:29:57 -04:00
|
|
|
|
2013-04-21 00:26:36 -04:00
|
|
|
```
|
|
|
|
devise :kerberos_authenticatable
|
|
|
|
attr_accessible :username
|
|
|
|
```
|
2013-04-21 00:29:57 -04:00
|
|
|
|
2013-04-21 00:26:36 -04:00
|
|
|
* Rebuild your Devise views automatically or by hand.
|
2013-04-21 00:29:57 -04:00
|
|
|
|
2013-04-21 00:26:36 -04:00
|
|
|
```
|
|
|
|
rake generate devise:views
|
|
|
|
```
|
|
|
|
|
|
|
|
##Other
|
|
|
|
* Currently only supports authentication and does not include password modification functionality.
|
|
|
|
* Initial code based largely on [devise_pam_authenticatable](https://github.com/jwilson511/devise_pam_authenticatable)
|