forked from External/greenlight
add LDAP authentication
This commit is contained in:
BIN
app/assets/images/ldap_icon.png
Normal file
BIN
app/assets/images/ldap_icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 22 KiB |
@ -16,6 +16,8 @@
|
||||
|
||||
class SessionsController < ApplicationController
|
||||
|
||||
skip_before_filter :verify_authenticity_token
|
||||
|
||||
def new
|
||||
end
|
||||
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
Reference in New Issue
Block a user