*/
protected $authxUf;
+ /**
+ * @var string
+ * Ex: 'send' or 'exception
+ */
+ protected $rejectMode = 'send';
+
/**
* Authenticator constructor.
*/
);
}
+ /**
+ * Specify the rejection mode.
+ *
+ * @param string $mode
+ * @return $this
+ */
+ public function setRejectMode(string $mode) {
+ $this->rejectMode = $mode;
+ return $this;
+ }
+
/**
* Reject a bad authentication attempt.
*
* @param string $message
*/
protected function reject($message = 'Authentication failed') {
+ if ($this->rejectMode === 'exception') {
+ throw new AuthxException($message);
+ }
+
\CRM_Core_Session::useFakeSession();
$r = new Response(401, ['Content-Type' => 'text/plain'], "HTTP 401 $message");
\CRM_Utils_System::sendResponse($r);
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+namespace Civi\Authx;
+
+class AuthxException extends \CRM_Core_Exception {
+
+}