gitlab_omniauth-ldap-2.2.0/ 0000755 0000041 0000041 00000000000 14256370317 015637 5 ustar www-data www-data gitlab_omniauth-ldap-2.2.0/.travis.yml 0000644 0000041 0000041 00000000133 14256370317 017745 0 ustar www-data www-data branches: only: - 'master' rvm: - 2.0.0 - 2.1.5 script: "bundle exec rspec spec" gitlab_omniauth-ldap-2.2.0/.rspec 0000644 0000041 0000041 00000000011 14256370317 016744 0 ustar www-data www-data --colour gitlab_omniauth-ldap-2.2.0/README.md 0000644 0000041 0000041 00000010732 14256370317 017121 0 ustar www-data www-data # GitLab fork | OmniAuth LDAP [](https://travis-ci.org/gitlabhq/omniauth-ldap) ### LDAP Use the LDAP strategy as a middleware in your application: use OmniAuth::Strategies::LDAP, :title => "My LDAP", :host => '10.101.10.1', :port => 389, :encryption => :plain, :base => 'dc=intridea, dc=com', :uid => 'sAMAccountName', :name_proc => Proc.new {|name| name.gsub(/@.*$/,'')}, :bind_dn => 'default_bind_dn', # Or, alternatively: #:filter => '(&(uid=%{username})(memberOf=cn=myapp-users,ou=groups,dc=example,dc=com))' :name_proc => Proc.new {|name| name.gsub(/@.*$/,'')} :bind_dn => 'default_bind_dn' :password => 'password' :tls_options => { :ssl_version => 'TLSv1_2', :ciphers => ["AES-128-CBC", "AES-128-CBC-HMAC-SHA1", "AES-128-CBC-HMAC-SHA256"] } All of the listed options are required, with the exception of :title, :name_proc, :bind_dn, and :password. - `encryption` is the type of encryption to use between this library and the LDAP server. `:plain` means no encryption. `:simple_tls` represents SSL/TLS (usually on port 636) while `:start_tls` represents StartTLS (usually port 389). - `:bind_dn` and `:password` are the default credentials to perform user lookup. most LDAP servers require that you supply a complete DN as a binding-credential, along with an authenticator such as a password. But for many applications, you often don’t have a full DN to identify the user. You usually get a simple identifier like a username or an email address, along with a password. Since many LDAP servers don't allow anonymous access, search function will require a bound connection, `:bind_dn` and `:password` will be required for searching on the username or email to retrieve the DN attribute for the user. If the LDAP server allows anonymous access, you don't need to provide these two parameters. - `:uid` is the LDAP attribute name for the user name in the login form. typically AD would be 'sAMAccountName' or 'UserPrincipalName', while OpenLDAP is 'uid'. - `:filter` is the LDAP filter used to search the user entry. It can be used in place of :uid for more flexibility. `%{username}` will be replaced by the user name processed by `:name_proc`. - `:name_proc` allows you to match the user name entered with the format of the :uid attributes. For example, value of 'sAMAccountName' in AD contains only the windows user name. If your user prefers using email to login, a name_proc as above will trim the email string down to just the windows login name. In summary, use `:name_proc` to fill the gap between the submitted username and LDAP uid attribute value. - `:try_sasl` and `:sasl_mechanisms` are optional. `:try_sasl` [`true` | `false`], `:sasl_mechanisms` [`'DIGEST-MD5'` | `'GSS-SPNEGO'`] Use them to initialize a SASL connection to server. If you are not familiar with these authentication methods, please just avoid them. - `:tls_options` allows you to pass in OpenSSL options like `:ssl_version`, `:ciphers` and more. See http://ruby-doc.org/stdlib-2.0.0/libdoc/openssl/rdoc/OpenSSL/SSL/SSLContext.html for all available options and values. Direct users to '/auth/ldap' to have them authenticated via your company's LDAP server. ## License Copyright (C) 2011 by Ping Yu and Intridea, Inc. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. gitlab_omniauth-ldap-2.2.0/spec/ 0000755 0000041 0000041 00000000000 14256370317 016571 5 ustar www-data www-data gitlab_omniauth-ldap-2.2.0/spec/omniauth/ 0000755 0000041 0000041 00000000000 14256370317 020415 5 ustar www-data www-data gitlab_omniauth-ldap-2.2.0/spec/omniauth/strategies/ 0000755 0000041 0000041 00000000000 14256370317 022567 5 ustar www-data www-data gitlab_omniauth-ldap-2.2.0/spec/omniauth/strategies/ldap_spec.rb 0000644 0000041 0000041 00000023415 14256370317 025053 0 ustar www-data www-data require 'spec_helper' describe "OmniAuth::Strategies::LDAP" do # :title => "My LDAP", # :host => '10.101.10.1', # :port => 389, # :method => :plain, # :verify_certificates => true, # :base => 'dc=intridea, dc=com', # :uid => 'sAMAccountName', # :name_proc => Proc.new {|name| name.gsub(/@.*$/,'')} # :bind_dn => 'default_bind_dn' # :password => 'password' class MyLdapProvider < OmniAuth::Strategies::LDAP; end let(:app) do Rack::Builder.new { use OmniAuth::Test::PhonySession use MyLdapProvider, :name => 'ldap', :title => 'MyLdap Form', :host => '192.168.1.145', :base => 'dc=score, dc=local', :name_proc => Proc.new {|name| name.gsub(/@.*$/,'')} run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] } }.to_app end let(:session) do last_request.env['rack.session'] end it 'should add a camelization for itself' do OmniAuth::Utils.camelize('ldap').should == 'LDAP' end describe '/auth/ldap' do let!(:csrf_token) { SecureRandom.base64(32) } let(:post_env) { make_env('/auth/ldap', 'rack.session' => { csrf: csrf_token }, 'rack.input' => StringIO.new("authenticity_token=#{escaped_token}")) } let(:escaped_token) { URI.encode_www_form_component(csrf_token, Encoding::UTF_8) } before(:each) { post '/auth/ldap', nil, post_env } def make_env(path = '/auth/ldap', props = {}) { 'REQUEST_METHOD' => 'POST', 'PATH_INFO' => path, 'rack.session' => {}, 'rack.input' => StringIO.new('test=true') }.merge(props) end it 'should display a form' do last_response.status.should == 200 last_response.body.should be_include("