ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
class.ilAuthFrontendCredentialsSoap.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 
24 {
30 
31  public function __construct(ServerRequestInterface $httpRequest, ilCtrlInterface $ctrl, ilSetting $settings)
32  {
33  global $DIC;
34  $this->main_tpl = $DIC->ui()->mainTemplate();
35  $this->authSession = $DIC['ilAuthSession'];
36  $this->httpRequest = $httpRequest;
37  $this->ctrl = $ctrl;
38  $this->settings = $settings;
40  }
41 
45  public function tryAuthenticationOnLoginPage(): void
46  {
47  $passedSso = '';
48  if (isset($this->httpRequest->getQueryParams()['passed_sso']) && is_string($this->httpRequest->getQueryParams()['passed_sso'])) {
49  $passedSso = $this->httpRequest->getQueryParams()['passed_sso'];
50  }
51 
52  if (!empty($passedSso)) {
53  return;
54  }
55 
56  if (!$this->settings->get('soap_auth_active', '')) {
57  return;
58  }
59 
60  if (empty($this->getUsername()) || empty($this->getPassword())) {
61  return;
62  }
63 
64  $this->logger->debug('Using SOAP authentication.');
65 
66  $status = ilAuthStatus::getInstance();
67 
68  $provider = new ilAuthProviderSoap($this);
69 
70  $frontend_factory = new ilAuthFrontendFactory();
71  $frontend_factory->setContext(ilAuthFrontendFactory::CONTEXT_STANDARD_FORM);
72  $frontend = $frontend_factory->getFrontend(
73  $this->authSession,
74  $status,
75  $this,
76  [$provider]
77  );
78  $frontend->authenticate();
79 
80  switch ($status->getStatus()) {
82  ilLoggerFactory::getLogger('auth')->debug(
83  'Redirecting to default starting page.'
84  );
86  break;
87 
89  $this->main_tpl->setOnScreenMessage('failure', $status->getTranslatedReason(), true);
90  $this->ctrl->redirectToURL(ilUtil::appendUrlParameterString(
91  $this->ctrl->getLinkTargetByClass('ilStartupGUI', 'showLoginPage', '', false, false),
92  'passed_sso=1'
93  ));
94  break;
95  }
96  }
97 }
static appendUrlParameterString(string $a_url, string $a_par, bool $xml_style=false)
static getLogger(string $a_component_id)
Get component logger.
tryAuthenticationOnLoginPage()
Check if an authentication attempt should be done when login page has been called.
__construct(ServerRequestInterface $httpRequest, ilCtrlInterface $ctrl, ilSetting $settings)
const int STATUS_AUTHENTICATED
$provider
Definition: ltitoken.php:80
global $DIC
Definition: shib_login.php:26
const int STATUS_AUTHENTICATION_FAILED
const int CONTEXT_STANDARD_FORM
Authentication with id and password.
static redirectToStartingPage(string $target='')
static getInstance()
Get status instance.
__construct(Container $dic, ilPlugin $plugin)