add LDAP authentication

This commit is contained in:
Josh
2017-07-05 16:26:27 -04:00
parent 9bbb669cc1
commit ae774b90ce
8 changed files with 58 additions and 1 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

View File

@ -16,6 +16,8 @@
class SessionsController < ApplicationController
skip_before_filter :verify_authenticity_token
def new
end

View File

@ -47,6 +47,14 @@ class User < ApplicationRecord
auth_hash['info']['email']
end
def self.ldap_username(auth_hash)
auth_hash['info']['nickname']
end
def self.ldap_email(auth_hash)
auth_hash['info']['email']
end
def set_encrypted_id
self.encrypted_id = "#{username[0..1]}-#{Digest::SHA1.hexdigest(uid+provider)[0..7]}"
end

View File

@ -49,6 +49,18 @@
</div>
<% end %>
<% end %>
<% if omniauth_providers_configured(:ldap) %>
<%= link_to omniauth_login_url(:ldap), class: "signin-link signin-link-ldap" do %>
<div class="signin-button center-block">
<div class="signin-icon-wrapper">
<%= image_tag(ENV['LDAP_ICON'].present? ? ENV['LDAP_ICON'] : 'ldap_icon.png', alt: "L", class: "signin-icon") %>
</div>
<div class="signin-text-wrapper text-center">
<span class="signin-text"><%= t('signin_text', provider: ENV['LDAP_NAME'].present? ? ENV['LDAP_NAME'] : 'LDAP') %></span>
</div>
</div>
<% end %>
<% end %>
</div>
<% end %>
</div>