• Модуль: main
  • Путь к файлу: ~/bitrix/modules/main/lib/server.php
  • Класс: BitrixMainServer
  • Вызов: Server::parseAuthRequest
public function parseAuthRequest()
{
	$digest = '';

	if ($this['PHP_AUTH_USER'] != '')
	{
		// Basic Authorization PHP module
		return [
			'basic' => [
				'username' => Encoding::convertEncodingToCurrent($this['PHP_AUTH_USER']),
				'password' => Encoding::convertEncodingToCurrent($this['PHP_AUTH_PW']),
			]
		];
	}
	elseif ($this['PHP_AUTH_DIGEST'] != '')
	{
		// Digest Authorization PHP module
		$digest = $this['PHP_AUTH_DIGEST'];
	}
	else
	{
		if ($this['REDIRECT_REMOTE_USER'] !== null || $this['REMOTE_USER'] !== null)
		{
			$res = $this['REDIRECT_REMOTE_USER'] ?? $this['REMOTE_USER'];
			if ($res != '')
			{
				if(preg_match('/^x20*Basicx20+([a-zA-Z0-9+/=]+)s*$/D', $res, $matches))
				{
					// Basic Authorization PHP FastCGI (CGI)
					$res = trim($matches[1]);
					$res = base64_decode($res);
					$res = Encoding::convertEncodingToCurrent($res);
					[$user, $pass] = explode(':', $res, 2);
					if (mb_strpos($user, $this['HTTP_HOST']."\") === 0)
					{
						$user = str_replace($this['HTTP_HOST']."\", "", $user);
					}
					elseif (mb_strpos($user, $this['SERVER_NAME']."\") === 0)
					{
						$user = str_replace($this['SERVER_NAME']."\", "", $user);
					}

					return [
						'basic' => [
							'username' => $user,
							'password' => $pass,
						]
					];
				}
				elseif (preg_match('/^x20*Digestx20+(.*)$/sD', $res, $matches))
				{
					// Digest Authorization PHP FastCGI (CGI)
					$digest = trim($matches[1]);
				}
			}
		}
	}

	if($digest <> '' && ($data = static::parseDigest($digest)))
	{
		return ['digest' => $data];
	}

	return false;
}