Sha256: b0b46684668d1ea38fb1fcf198a797d474f3562ddcdf8592236c34b1feb92cf1

Contents?: true

Size: 1.21 KB

Versions: 61

Compression:

Stored size: 1.21 KB

Contents

require 'apps/core/auth/lib/authenticator'
require 'digest/md5'

module Spider; module Auth
    
    module DigestAuthenticator
        include Authenticable
        
        def self.included(klass)
            klass.extend(ClassMethods)
            klass.extend(Authenticable::ClassMethods)
            klass.register_authentication(:digest)
        end
        
        module ClassMethods
        
            def authenticate_digest(params)
                login = params[:login]
                password = params[:password]
                realm = password[:ha1]
                ha1 = self.ha1(login, password, realm)
                user = find(:username => login, :realm => realm, :ha1 => ha1)
                if (user.length == 1)
                    return user[0].uid
                end
                return nil
            end
        
            def find_by_ha1
                user = DigestUser.find(:ha1 => ha1)
                return user[0] if (user.length == 1)
                return nil
            end
        
            def ha1(login, password, realm)
                Digest::MD5::hexdigest("#{login}:#{password}:#{realm}")
            end
            
            
        end
        
    end
    
end; end

Version data entries

61 entries across 61 versions & 1 rubygems

Version Path
spiderfw-1.0.1 apps/core/auth/lib/digest_authenticator.rb
spiderfw-1.0.0 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.39 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.38 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.37 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.35 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.34 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.33 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.32 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.31 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.30 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.29 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.28 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.27 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.26 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.26.pre1 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.25 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.24 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.23 apps/core/auth/lib/digest_authenticator.rb
spiderfw-0.6.22 apps/core/auth/lib/digest_authenticator.rb