Commit d8d33681dd33c22e7156ab77b34ef7cf3b731fa7
Committed by
Alexandre Barbosa
1 parent
5ade08fe
Exists in
master
Change ldap auth to colab remote database auth
Showing
1 changed file
with
5 additions
and
13 deletions
Show diff stats
lib/omniauth/strategies/env.rb
| 1 | # Based on code from the oa-env gem | 1 | # Based on code from the oa-env gem |
| 2 | - | 2 | +require 'pg' |
| 3 | require 'omniauth' | 3 | require 'omniauth' |
| 4 | require 'omniauth-ldap/adaptor' | 4 | require 'omniauth-ldap/adaptor' |
| 5 | 5 | ||
| @@ -42,18 +42,10 @@ module OmniAuth | @@ -42,18 +42,10 @@ module OmniAuth | ||
| 42 | private | 42 | private |
| 43 | 43 | ||
| 44 | def fill_ldap_info | 44 | def fill_ldap_info |
| 45 | - ldap = Net::LDAP.new :host => @options[:host], | ||
| 46 | - :port => @options[:port], | ||
| 47 | - :auth => { | ||
| 48 | - :method => :simple, | ||
| 49 | - :username => @options[:bind_dn], | ||
| 50 | - :password => @options[:password] | ||
| 51 | - } | ||
| 52 | - filter = Net::LDAP::Filter.eq('uid', @uid) | ||
| 53 | - ldap.search(:base => @options[:base], filter: filter) do |entry| | ||
| 54 | - @user_data[:name] = "#{entry.givenname.first} #{entry.sn.first}" | ||
| 55 | - @user_data[:email] = entry.mail.first | ||
| 56 | - end | 45 | + conn = PG::Connection.open(:dbname => 'colab', :host => 'localhost', :user => 'colab', :password => 'colab') |
| 46 | + res = conn.exec("select email, first_name from accounts_user where username='#{@uid}';") | ||
| 47 | + @user_data[:email] = res[0]['email'] | ||
| 48 | + @user_data[:name] = res[0]['first_name'] | ||
| 57 | end | 49 | end |
| 58 | end | 50 | end |
| 59 | end | 51 | end |