module Devise::Models::RadiusAuthenticatable::ClassMethods
Public Instance Methods
Invoked by the RadiusAuthenticatable
stratgey to perform the authentication against the radius server. The username is extracted from the authentication hash and a UID is generated from the username and server IP. We then search for an existing resource using the UID and configured UID field. If no resource is found, a new resource is built (not created). If authentication is successful the callback is responsible for saving the resource. Returns the resource if authentication succeeds and nil if it does not.
# File lib/devise/models/radius_authenticatable.rb, line 142 def find_for_radius_authentication(authentication_hash) uid_field = self.radius_uid_field.to_sym username, password = radius_credentials(authentication_hash) uid = self.radius_uid_generator.call(username, self.radius_server) resource = find_for_authentication({ uid_field => uid }) || new(uid_field => uid) resource.valid_radius_password?(username, password) ? resource : nil end
Extract the username and password from the supplied authentication hash. The username is extracted using the first value from Devise.authentication_keys
. The username is converted to lowercase if the authentication key is in the list of case insensitive keys configured for Devise
.
# File lib/devise/models/radius_authenticatable.rb, line 157 def radius_credentials(authentication_hash) key = self.authentication_keys.first value = authentication_hash[key] value.downcase! if (self.case_insensitive_keys || []).include?(key) [value, authentication_hash[:password]] end
Returns an enumerable that provides each server with it's configured port. If no port is given with the server config, the default +radius_server_port is used.
# File lib/devise/models/radius_authenticatable.rb, line 168 def radius_servers_with_ports @radius_servers_with_ports ||= begin retval = [] servers = self.radius_servers servers += [self.radius_server] if self.radius_server servers.each do |server| server, port = server.split(':') port ||= self.radius_server_port retval << [server, port] end retval end end