Sha256: c45d4e8cbb12c840cf2867ead7c4c03f145426d12c19aa012d475cb1403570b0

Contents?: true

Size: 1.08 KB

Versions: 4

Compression:

Stored size: 1.08 KB

Contents

require 'devise/strategies/authenticatable'

module Devise
  module Strategies
    # Strategy for authenticating users with a radius server.  If authentication with
    # the radius server fails, allow warden to move on to the next strategy.  When
    # authentication succeeds and Devise indicates that the resource has been
    # successfully validated, invoke the +after_radius_authentication+ callback on the
    # resource and let warden know we were successful and not to continue with executing
    # further strategies.
    class RadiusAuthenticatable < Authenticatable
      # Invoked by warden to execute the strategy.
      def authenticate!
        auth_params = authentication_hash.merge(password: password)

        resource = valid_password? &&
          mapping.to.find_for_radius_authentication(auth_params)

        return fail(:invalid) unless resource

        if validate(resource)
          resource.after_radius_authentication
          success!(resource)
        end
      end
    end
  end
end

Warden::Strategies.add(:radius_authenticatable, Devise::Strategies::RadiusAuthenticatable)

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
devise-multi-radius-authenticatable-0.3.0 lib/devise/strategies/radius_authenticatable.rb
devise-multi-radius-authenticatable-0.2.0 lib/devise/strategies/radius_authenticatable.rb
devise-multi-radius-authenticatable-0.1.2 lib/devise/strategies/radius_authenticatable.rb
devise-multi-radius-authenticatable-0.1.1 lib/devise/strategies/radius_authenticatable.rb