/** * Authenticates the identity contained in a request. Will use the `settings.userModel`, and `settings.fields` * to find POST data that is used to find a matching record in the `settings.userModel`. Will return false if * there is no post data, either username or password is missing, of if the scope conditions have not been met. * @author DaiNT * @date: 2013/05/23 * @param CakeRequest $request The request that contains login information. * @param CakeResponse $response Unused response object. * @return mixed. False on login failure. An array of User data on success. */ public function authenticate(CakeRequest $request, CakeResponse $response) { if (isset($request->data['type'])) { $type = $request->data['type']; if (!isset($this->settings['types'][$type])) { throw new Exception(__('Type %s login not setting', $type)); } $types = $this->settings['types']; $this->settings = array_merge(array('types' => $types), $types[$type]); } // if not set model in from then reset to request if (AppUtility::checkIsMobile()) { $this->settings['fields']['password'] = '******'; } $fields = $this->settings['fields']; $model = $this->settings['userModel']; $userName = Sanitize::paranoid($request->data[$model][$fields['username']]); $password = Sanitize::paranoid($request->data[$model][$fields['password']]); if (empty($request->data[$model])) { $request->data[$model] = array($fields['username'] => isset($userName) ? $userName : null, $fields['password'] => isset($password) ? $password : null); } $user = parent::authenticate($request, $response); if (!empty($user) && is_array($user) && isset($request->data[$model]['system_permission'])) { $user['system_permission'] = $request->data[$model]['system_permission']; } return $user; }
public function authenticate(CakeRequest $request, CakeResponse $response) { foreach (Configure::read('brwSettings.userModels') as $userModel) { $this->settings['userModel'] = $userModel; $request->data[$userModel] = $request->data['BrwUser']; $authenticated = parent::authenticate($request, $response); if ($authenticated) { ClassRegistry::init($userModel)->updateLastLogin($authenticated['id']); return array_merge($authenticated, array('model' => $userModel)); } } $newUser = ClassRegistry::init('BrwUser')->checkAndCreate($request->data['BrwUser']['email'], $request->data['BrwUser']['password']); if ($newUser) { return array_merge($newUser, array('model' => 'BrwUser')); } return false; }
/** * Initializes a SimpleSAML_Auth_Simple object. * * @param string $authSource The ID of the authentication source to use. This will * override the authentication source set in `app/Config/bootstrap.php`. */ public function __construct(ComponentCollection $collection, array $settings, string $authSource = NULL) { parent::__construct($collection, $settings); // Check the config if (Configure::read('Saml.SimpleSamlPath') != NULL) { $this->path = Configure::read('Saml.SimpleSamlPath'); } else { throw new Exception('Parameter Saml.SimpleSamlPath is missing from the configuration file.'); } if ($authSource != NULL) { $this->authSource = $authSource; } elseif (Configure::read('Saml.AuthSource') != NULL) { $this->authSource = Configure::read('Saml.AuthSource'); } // Initialize simpleSAMLphp require_once $this->path . '/lib/_autoload.php'; $this->as = new SimpleSAML_Auth_Simple($this->authSource); }
/** * Constructor. Sets default passwordHasher to Blowfish * * @param ComponentCollection $collection The Component collection used on this request. * @param array $settings Array of settings to use. */ public function __construct(ComponentCollection $collection, $settings) { $this->settings['passwordHasher'] = 'Blowfish'; parent::__construct($collection, $settings); }