gitlab_omniauth-ldap 2.0.3 → 2.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG +3 -0
- data/lib/omniauth-ldap/version.rb +1 -1
- data/lib/omniauth/strategies/ldap.rb +7 -2
- data/spec/omniauth/strategies/ldap_spec.rb +10 -6
- metadata +3 -3
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 4d5b4eb5376fab8ef4f9e5e006ba83aa214402e0
         | 
| 4 | 
            +
              data.tar.gz: 372d5d8f78a286cfe1328695f11323704a8297b6
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: e2154945f44fa50434692911fafa1fdc098d4758603c6391be558b701ae4f87b712aef88501c98fa00dda0160e74995172067f9c24f97b051da29e8145f4e0bf
         | 
| 7 | 
            +
              data.tar.gz: 5d9b8cd9c5e488f1a643c6bae705f79290bcf04588a50e638bc1d6a80e2d67ba3fedfd122d4ca405b32e58a7fa0edcd0f58ef6736dba02876bf7bfdfab122e4e
         | 
    
        data/CHANGELOG
    CHANGED
    
    
| @@ -4,6 +4,9 @@ module OmniAuth | |
| 4 4 | 
             
              module Strategies
         | 
| 5 5 | 
             
                class LDAP
         | 
| 6 6 | 
             
                  include OmniAuth::Strategy
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  InvalidCredentialsError = Class.new(StandardError)
         | 
| 9 | 
            +
             | 
| 7 10 | 
             
                  @@config = {
         | 
| 8 11 | 
             
                    'name' => 'cn',
         | 
| 9 12 | 
             
                    'first_name' => 'givenName',
         | 
| @@ -45,7 +48,9 @@ module OmniAuth | |
| 45 48 | 
             
                    begin
         | 
| 46 49 | 
             
                      @ldap_user_info = @adaptor.bind_as(:filter => filter(@adaptor), :size => 1, :password => request['password'])
         | 
| 47 50 |  | 
| 48 | 
            -
                       | 
| 51 | 
            +
                      unless @ldap_user_info
         | 
| 52 | 
            +
                        return fail!(:invalid_credentials, InvalidCredentialsError.new("Invalid credentials for #{request['username']}"))
         | 
| 53 | 
            +
                      end
         | 
| 49 54 |  | 
| 50 55 | 
             
                      @user_info = self.class.map_user(@@config, @ldap_user_info)
         | 
| 51 56 | 
             
                      super
         | 
| @@ -54,7 +59,7 @@ module OmniAuth | |
| 54 59 | 
             
                    end
         | 
| 55 60 | 
             
                  end
         | 
| 56 61 |  | 
| 57 | 
            -
                  def filter | 
| 62 | 
            +
                  def filter(adaptor)
         | 
| 58 63 | 
             
                    if adaptor.filter and !adaptor.filter.empty?
         | 
| 59 64 | 
             
                      username = Net::LDAP::Filter.escape(@options[:name_proc].call(request['username']))
         | 
| 60 65 | 
             
                      Net::LDAP::Filter.construct(adaptor.filter % { username: username })
         | 
| @@ -69,8 +69,10 @@ describe "OmniAuth::Strategies::LDAP" do | |
| 69 69 |  | 
| 70 70 | 
             
                  it 'should redirect to error page' do
         | 
| 71 71 | 
             
                    post('/auth/ldap/callback', {:username => 'ping', :password => 'password'})
         | 
| 72 | 
            -
             | 
| 73 | 
            -
                    last_response. | 
| 72 | 
            +
             | 
| 73 | 
            +
                    expect(last_response).to be_redirect
         | 
| 74 | 
            +
                    expect(last_response.headers['Location']).to match('invalid_credentials')
         | 
| 75 | 
            +
                    expect(last_request.env['omniauth.error'].message).to eq('Invalid credentials for ping')
         | 
| 74 76 | 
             
                  end
         | 
| 75 77 |  | 
| 76 78 | 
             
                  it 'should redirect to error page when there is exception' do
         | 
| @@ -132,8 +134,9 @@ describe "OmniAuth::Strategies::LDAP" do | |
| 132 134 | 
             
                      it 'should redirect to error page' do
         | 
| 133 135 | 
             
                        post('/auth/ldap/callback', {:username => 'ping', :password => 'password'})
         | 
| 134 136 |  | 
| 135 | 
            -
                        last_response. | 
| 136 | 
            -
                        last_response.headers['Location']. | 
| 137 | 
            +
                        expect(last_response).to be_redirect
         | 
| 138 | 
            +
                        expect(last_response.headers['Location']).to match('invalid_credentials')
         | 
| 139 | 
            +
                        expect(last_request.env['omniauth.error'].message).to eq('Invalid credentials for ping')
         | 
| 137 140 | 
             
                      end
         | 
| 138 141 | 
             
                      context 'and filter is set' do
         | 
| 139 142 | 
             
                        it 'should bind with filter' do
         | 
| @@ -141,8 +144,9 @@ describe "OmniAuth::Strategies::LDAP" do | |
| 141 144 | 
             
                          Net::LDAP::Filter.should_receive(:construct).with('uid=ping')
         | 
| 142 145 | 
             
                          post('/auth/ldap/callback', {:username => 'ping', :password => 'password'})
         | 
| 143 146 |  | 
| 144 | 
            -
                          last_response. | 
| 145 | 
            -
                          last_response.headers['Location']. | 
| 147 | 
            +
                          expect(last_response).to be_redirect
         | 
| 148 | 
            +
                          expect(last_response.headers['Location']).to match('invalid_credentials')
         | 
| 149 | 
            +
                          expect(last_request.env['omniauth.error'].message).to eq('Invalid credentials for ping')
         | 
| 146 150 | 
             
                        end
         | 
| 147 151 | 
             
                      end
         | 
| 148 152 |  | 
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: gitlab_omniauth-ldap
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 2.0. | 
| 4 | 
            +
              version: 2.0.4
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Ping Yu
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2017- | 
| 11 | 
            +
            date: 2017-08-10 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: omniauth
         | 
| @@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement | |
| 172 172 | 
             
                  version: '0'
         | 
| 173 173 | 
             
            requirements: []
         | 
| 174 174 | 
             
            rubyforge_project: 
         | 
| 175 | 
            -
            rubygems_version: 2. | 
| 175 | 
            +
            rubygems_version: 2.6.8
         | 
| 176 176 | 
             
            signing_key: 
         | 
| 177 177 | 
             
            specification_version: 4
         | 
| 178 178 | 
             
            summary: A LDAP strategy for OmniAuth.
         |