|
1
|
|
|
<?php |
|
2
|
|
|
/** |
|
3
|
|
|
* Facades for Yii 2 |
|
4
|
|
|
* |
|
5
|
|
|
* Generated on Yii 2.0.12 |
|
6
|
|
|
* |
|
7
|
|
|
* @see https://github.com/sergeymakinen/yii2-facades |
|
8
|
|
|
* @copyright Copyright (c) 2016-2017 Sergey Makinen (https://makinen.ru) |
|
9
|
|
|
* @license https://github.com/sergeymakinen/yii2-facades/blob/master/LICENSE The MIT License |
|
10
|
|
|
*/ |
|
11
|
|
|
|
|
12
|
|
|
namespace sergeymakinen\facades; |
|
13
|
|
|
|
|
14
|
|
|
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */ |
|
15
|
|
|
/** |
|
16
|
|
|
* Yii::$app->get('security') facade. |
|
17
|
|
|
* |
|
18
|
|
|
* Methods |
|
19
|
|
|
* |
|
20
|
|
|
* @method static \yii\base\Behavior attachBehavior(string $name, string|array|\yii\base\Behavior $behavior) Attaches a behavior to this component. |
|
21
|
|
|
* @see \yii\base\Component::attachBehavior |
|
22
|
|
|
* |
|
23
|
|
|
* @method static void attachBehaviors(array $behaviors) Attaches a list of behaviors to the component. |
|
24
|
|
|
* @see \yii\base\Component::attachBehaviors |
|
25
|
|
|
* |
|
26
|
|
|
* @method static array behaviors() Returns a list of behaviors that this component should behave as. |
|
27
|
|
|
* @see \yii\base\Component::behaviors |
|
28
|
|
|
* |
|
29
|
|
|
* @method static bool compareString($expected, string $actual) Performs string comparison using timing attack resistant approach. |
|
30
|
|
|
* @see \yii\base\Security::compareString |
|
31
|
|
|
* |
|
32
|
|
|
* @method static bool|string decryptByKey(string $data, string $inputKey, string $info = null) Verifies and decrypts data encrypted with [[encryptByKey()]]. |
|
33
|
|
|
* @see \yii\base\Security::decryptByKey |
|
34
|
|
|
* |
|
35
|
|
|
* @method static bool|string decryptByPassword(string $data, string $password) Verifies and decrypts data encrypted with [[encryptByPassword()]]. |
|
36
|
|
|
* @see \yii\base\Security::decryptByPassword |
|
37
|
|
|
* |
|
38
|
|
|
* @method static null|\yii\base\Behavior detachBehavior(string $name) Detaches a behavior from the component. |
|
39
|
|
|
* @see \yii\base\Component::detachBehavior |
|
40
|
|
|
* |
|
41
|
|
|
* @method static void detachBehaviors() Detaches all behaviors from the component. |
|
42
|
|
|
* @see \yii\base\Component::detachBehaviors |
|
43
|
|
|
* |
|
44
|
|
|
* @method static string encryptByKey(string $data, string $inputKey, string $info = null) Encrypts data using a cryptographic key. |
|
45
|
|
|
* @see \yii\base\Security::encryptByKey |
|
46
|
|
|
* |
|
47
|
|
|
* @method static string encryptByPassword(string $data, string $password) Encrypts data using a password. |
|
48
|
|
|
* @see \yii\base\Security::encryptByPassword |
|
49
|
|
|
* |
|
50
|
|
|
* @method static void ensureBehaviors() Makes sure that the behaviors declared in [[behaviors()]] are attached to this component. |
|
51
|
|
|
* @see \yii\base\Component::ensureBehaviors |
|
52
|
|
|
* |
|
53
|
|
|
* @method static string generatePasswordHash(string $password, int $cost = null) Generates a secure hash from a password and a random salt. |
|
54
|
|
|
* @see \yii\base\Security::generatePasswordHash |
|
55
|
|
|
* |
|
56
|
|
|
* @method static string generateRandomKey(int $length = 32) Generates specified number of random bytes. |
|
57
|
|
|
* @see \yii\base\Security::generateRandomKey |
|
58
|
|
|
* |
|
59
|
|
|
* @method static string generateRandomString(int $length = 32) Generates a random string of specified length. |
|
60
|
|
|
* @see \yii\base\Security::generateRandomString |
|
61
|
|
|
* |
|
62
|
|
|
* @method static null|\yii\base\Behavior getBehavior(string $name) Returns the named behavior object. |
|
63
|
|
|
* @see \yii\base\Component::getBehavior |
|
64
|
|
|
* |
|
65
|
|
|
* @method static \yii\base\Behavior[] getBehaviors() Returns all behaviors attached to this component. |
|
66
|
|
|
* @see \yii\base\Component::getBehaviors |
|
67
|
|
|
* |
|
68
|
|
|
* @method static bool hasEventHandlers(string $name) Returns a value indicating whether there is any handler attached to the named event. |
|
69
|
|
|
* @see \yii\base\Component::hasEventHandlers |
|
70
|
|
|
* |
|
71
|
|
|
* @method static string hashData(string $data, string $key, bool $rawHash = false) Prefixes data with a keyed hash value so that it can later be detected if it is tampered. |
|
72
|
|
|
* @see \yii\base\Security::hashData |
|
73
|
|
|
* |
|
74
|
|
|
* @method static string hkdf(string $algo, string $inputKey, string $salt = null, string $info = null, int $length = 0) Derives a key from the given input key using the standard HKDF algorithm. |
|
75
|
|
|
* @see \yii\base\Security::hkdf |
|
76
|
|
|
* |
|
77
|
|
|
* @method static string maskToken(string $token) Masks a token to make it uncompressible. |
|
78
|
|
|
* @see \yii\base\Security::maskToken |
|
79
|
|
|
* |
|
80
|
|
|
* @method static bool off(string $name, callable $handler = null) Detaches an existing event handler from this component. |
|
81
|
|
|
* @see \yii\base\Component::off |
|
82
|
|
|
* |
|
83
|
|
|
* @method static void on(string $name, callable $handler, mixed $data = null, bool $append = true) Attaches an event handler to an event. |
|
84
|
|
|
* @see \yii\base\Component::on |
|
85
|
|
|
* |
|
86
|
|
|
* @method static string pbkdf2(string $algo, string $password, string $salt, int $iterations, int $length = 0) Derives a key from the given password using the standard PBKDF2 algorithm. |
|
87
|
|
|
* @see \yii\base\Security::pbkdf2 |
|
88
|
|
|
* |
|
89
|
|
|
* @method static void trigger(string $name, \yii\base\Event $event = null) Triggers an event. |
|
90
|
|
|
* @see \yii\base\Component::trigger |
|
91
|
|
|
* |
|
92
|
|
|
* @method static string unmaskToken(string $maskedToken) Unmasks a token previously masked by `maskToken`. |
|
93
|
|
|
* @see \yii\base\Security::unmaskToken |
|
94
|
|
|
* |
|
95
|
|
|
* @method static string|bool validateData(string $data, string $key, bool $rawHash = false) Validates if the given data is tampered. |
|
96
|
|
|
* @see \yii\base\Security::validateData |
|
97
|
|
|
* |
|
98
|
|
|
* @method static bool validatePassword(string $password, string $hash) Verifies a password against a hash. |
|
99
|
|
|
* @see \yii\base\Security::validatePassword |
|
100
|
|
|
* |
|
101
|
|
|
* Property accessors |
|
102
|
|
|
* |
|
103
|
|
|
* @method static array[] getAllowedCiphers() Returns Look-up table of block sizes and key sizes for each supported OpenSSL cipher. |
|
104
|
|
|
* @see \yii\base\Security::allowedCiphers |
|
105
|
|
|
* |
|
106
|
|
|
* @method static string getAuthKeyInfo() Returns HKDF info value for derivation of message authentication key. |
|
107
|
|
|
* @see \yii\base\Security::authKeyInfo |
|
108
|
|
|
* |
|
109
|
|
|
* @method static string getCipher() Returns The cipher to use for encryption and decryption. |
|
110
|
|
|
* @see \yii\base\Security::cipher |
|
111
|
|
|
* |
|
112
|
|
|
* @method static int getDerivationIterations() Returns derivation iterations count. |
|
113
|
|
|
* @see \yii\base\Security::derivationIterations |
|
114
|
|
|
* |
|
115
|
|
|
* @method static string getKdfHash() Returns Hash algorithm for key derivation. |
|
116
|
|
|
* @see \yii\base\Security::kdfHash |
|
117
|
|
|
* |
|
118
|
|
|
* @method static string getMacHash() Returns Hash algorithm for message authentication. |
|
119
|
|
|
* @see \yii\base\Security::macHash |
|
120
|
|
|
* |
|
121
|
|
|
* @method static int getPasswordHashCost() Returns Default cost used for password hashing. |
|
122
|
|
|
* @see \yii\base\Security::passwordHashCost |
|
123
|
|
|
* |
|
124
|
|
|
* @method static string getPasswordHashStrategy() Returns strategy, which should be used to generate password hash. |
|
125
|
|
|
* @see \yii\base\Security::passwordHashStrategy |
|
126
|
|
|
* |
|
127
|
|
|
* @method static void setAllowedCiphers(array[] $value) Sets Look-up table of block sizes and key sizes for each supported OpenSSL cipher. |
|
128
|
|
|
* @see \yii\base\Security::allowedCiphers |
|
129
|
|
|
* |
|
130
|
|
|
* @method static void setAuthKeyInfo(string $value) Sets HKDF info value for derivation of message authentication key. |
|
131
|
|
|
* @see \yii\base\Security::authKeyInfo |
|
132
|
|
|
* |
|
133
|
|
|
* @method static void setCipher(string $value) Sets The cipher to use for encryption and decryption. |
|
134
|
|
|
* @see \yii\base\Security::cipher |
|
135
|
|
|
* |
|
136
|
|
|
* @method static void setDerivationIterations(int $value) Sets derivation iterations count. |
|
137
|
|
|
* @see \yii\base\Security::derivationIterations |
|
138
|
|
|
* |
|
139
|
|
|
* @method static void setKdfHash(string $value) Sets Hash algorithm for key derivation. |
|
140
|
|
|
* @see \yii\base\Security::kdfHash |
|
141
|
|
|
* |
|
142
|
|
|
* @method static void setMacHash(string $value) Sets Hash algorithm for message authentication. |
|
143
|
|
|
* @see \yii\base\Security::macHash |
|
144
|
|
|
* |
|
145
|
|
|
* @method static void setPasswordHashCost(int $value) Sets Default cost used for password hashing. |
|
146
|
|
|
* @see \yii\base\Security::passwordHashCost |
|
147
|
|
|
* |
|
148
|
|
|
* @method static void setPasswordHashStrategy(string $value) Sets strategy, which should be used to generate password hash. |
|
149
|
|
|
* @see \yii\base\Security::passwordHashStrategy |
|
150
|
|
|
*/ |
|
151
|
|
|
class Security extends Facade |
|
152
|
|
|
{ |
|
153
|
|
|
/** |
|
154
|
|
|
* @inheritDoc |
|
155
|
|
|
*/ |
|
156
|
1 |
|
public static function getFacadeComponentId() |
|
157
|
|
|
{ |
|
158
|
1 |
|
return 'security'; |
|
159
|
|
|
} |
|
160
|
|
|
} |
|
161
|
|
|
|