1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
authtype.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Rest\Engine\ActionFilter
;
4
5
use
Bitrix\Main\Error
;
6
use
Bitrix\Main\Event
;
7
use
Bitrix\Main\EventResult
;
8
use
Bitrix\Rest
;
9
14
class
AuthType
extends
Base
15
{
16
public
const
PASSWORD
= 0b00000001;
17
public
const
APPLICATION
= 0b00000010;
18
public
const
SESSION
= 0b00000100;
19
20
public
const
ALL
= self::APPLICATION | self::PASSWORD | self::SESSION;
21
22
public
const
ERROR_INSUFFICIENT_AUTH_TYPE
=
'insufficient_auth_type'
;
23
24
private
$types;
25
26
public
function
__construct
($types)
27
{
28
$this->types = $types;
29
parent::__construct();
30
}
31
32
public
function
onBeforeAction
(
Event
$event
)
33
{
34
$scope = $this->
getCurrentAuthType
();
35
if
(($this->types & $scope) === $scope)
36
{
37
return
null
;
38
}
39
40
$this->
addError
(
new
Error
(
'The request requires higher privileges than provided.'
, self::ERROR_INSUFFICIENT_AUTH_TYPE));
41
42
return
new
EventResult
(EventResult::ERROR,
null
,
null
, $this);
43
}
44
45
protected
function
getCurrentAuthType
() : ?int
46
{
47
$server = $this->
getRestServer
();
48
if
($server)
49
{
50
switch
($server->getAuthType())
51
{
52
case
Rest\APAuth\Auth::AUTH_TYPE
:
53
return
static::PASSWORD;
54
case
Rest\OAuth\Auth::AUTH_TYPE
:
55
return
static::APPLICATION;
56
case
Rest\SessionAuth\Auth::AUTH_TYPE
:
57
return
static::SESSION;
58
}
59
}
60
61
return
null
;
62
}
63
}
Bitrix\Main\Engine\ActionFilter\Base\addError
addError(Error $error)
Определения
base.php:80
Bitrix\Main\Error
Определения
error.php:15
Bitrix\Main\Event
Определения
event.php:5
Bitrix\Main\EventResult
Определения
eventresult.php:5
Bitrix\Rest\APAuth\Auth\AUTH_TYPE
const AUTH_TYPE
Определения
auth.php:23
Bitrix\Rest\Engine\ActionFilter\AuthType
Определения
authtype.php:15
Bitrix\Rest\Engine\ActionFilter\AuthType\PASSWORD
const PASSWORD
Определения
authtype.php:16
Bitrix\Rest\Engine\ActionFilter\AuthType\onBeforeAction
onBeforeAction(Event $event)
Определения
authtype.php:32
Bitrix\Rest\Engine\ActionFilter\AuthType\getCurrentAuthType
getCurrentAuthType()
Определения
authtype.php:45
Bitrix\Rest\Engine\ActionFilter\AuthType\__construct
__construct($types)
Определения
authtype.php:26
Bitrix\Rest\Engine\ActionFilter\AuthType\ALL
const ALL
Определения
authtype.php:20
Bitrix\Rest\Engine\ActionFilter\AuthType\ERROR_INSUFFICIENT_AUTH_TYPE
const ERROR_INSUFFICIENT_AUTH_TYPE
Определения
authtype.php:22
Bitrix\Rest\Engine\ActionFilter\AuthType\APPLICATION
const APPLICATION
Определения
authtype.php:17
Bitrix\Rest\Engine\ActionFilter\AuthType\SESSION
const SESSION
Определения
authtype.php:18
Bitrix\Rest\Engine\ActionFilter\Base
Определения
base.php:13
Bitrix\Rest\Engine\ActionFilter\Base\getRestServer
getRestServer()
Определения
base.php:28
Bitrix\Rest\OAuth\Auth\AUTH_TYPE
const AUTH_TYPE
Определения
auth.php:25
Bitrix\Rest\SessionAuth\Auth\AUTH_TYPE
const AUTH_TYPE
Определения
auth.php:18
Bitrix\Rest\Engine\ActionFilter
Определения
authtype.php:3
Bitrix\Rest\Event
Определения
buffer.php:3
Bitrix\Rest
Определения
accessexception.php:2
$event
$event
Определения
prolog_after.php:141
bitrix
modules
rest
lib
engine
actionfilter
authtype.php
Создано системой
1.14.0