Commit f0dddf43853978daa8be6cb86611cb73faff4ef1
1 parent
d909c833
Exists in
master
remove temp file
Showing
1 changed file
with
0 additions
and
40 deletions
Show diff stats
lib/omniauth/strategies/env.rb~
@@ -1,40 +0,0 @@ | @@ -1,40 +0,0 @@ | ||
1 | -require 'omniauth' | ||
2 | -require 'omniauth-ldap/adaptor' | ||
3 | - | ||
4 | -module OmniAuth | ||
5 | - module Strategies | ||
6 | - class Env | ||
7 | - include OmniAuth::Strategy | ||
8 | - | ||
9 | - def request_phase | ||
10 | - @user_data = {} | ||
11 | - @uid = env['HTTP_REMOTE_USER'] | ||
12 | - return fail![:no_user] unless @uid | ||
13 | - | ||
14 | - fill_ldap_info unless @options.empty? | ||
15 | - | ||
16 | - @env['omniauth.auth'] = auth_hash | ||
17 | - @env['REQUEST_METHOD'] = 'GET' | ||
18 | - @env['PATH_INFO'] = "#{OmniAuth.config.path_prefix}/#{name}/callback" | ||
19 | - | ||
20 | - call_app! | ||
21 | - end | ||
22 | - | ||
23 | - uid { @uid } | ||
24 | - | ||
25 | - info { @user_data } | ||
26 | - | ||
27 | - private | ||
28 | - | ||
29 | - def fill_ldap_info | ||
30 | - adaptor = OmniAuth::LDAP::Adaptor.new @options | ||
31 | - | ||
32 | - filter = Net::LDAP::Filter.eq('cn', @uid) | ||
33 | - adaptor.connection.search(base: @options[:base], filter: filter) do |entry| | ||
34 | - @user_data[:name] = "#{entry.givenname.first} #{entry.sn.first}" | ||
35 | - @user_data[:email] = entry.mail.first | ||
36 | - end | ||
37 | - end | ||
38 | - end | ||
39 | - end | ||
40 | -end |