Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
Y
yii2
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PSDI Army
yii2
Commits
2bab6259
Commit
2bab6259
authored
Jun 27, 2014
by
Klimov Paul
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
'Security' helper usage switched to 'security' application component.
parent
54ac875e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
16 deletions
+12
-16
User.php
apps/advanced/common/models/User.php
+5
-5
user.php
apps/advanced/common/tests/templates/fixtures/user.php
+3
-5
Request.php
framework/web/Request.php
+3
-4
Response.php
framework/web/Response.php
+1
-2
No files found.
apps/advanced/common/models/User.php
View file @
2bab6259
...
...
@@ -3,7 +3,7 @@ namespace common\models;
use
yii\base\NotSupportedException
;
use
yii\db\ActiveRecord
;
use
yii\helpers\Security
;
use
Yii
;
use
yii\web\IdentityInterface
;
/**
...
...
@@ -147,7 +147,7 @@ class User extends ActiveRecord implements IdentityInterface
*/
public
function
validatePassword
(
$password
)
{
return
Security
::
validatePassword
(
$password
,
$this
->
password_hash
);
return
Yii
::
$app
->
getSecurity
()
->
validatePassword
(
$password
,
$this
->
password_hash
);
}
/**
...
...
@@ -157,7 +157,7 @@ class User extends ActiveRecord implements IdentityInterface
*/
public
function
setPassword
(
$password
)
{
$this
->
password_hash
=
Security
::
generatePasswordHash
(
$password
);
$this
->
password_hash
=
Yii
::
$app
->
getSecurity
()
->
generatePasswordHash
(
$password
);
}
/**
...
...
@@ -165,7 +165,7 @@ class User extends ActiveRecord implements IdentityInterface
*/
public
function
generateAuthKey
()
{
$this
->
auth_key
=
Security
::
generateRandomKey
();
$this
->
auth_key
=
Yii
::
$app
->
getSecurity
()
->
generateRandomKey
();
}
/**
...
...
@@ -173,7 +173,7 @@ class User extends ActiveRecord implements IdentityInterface
*/
public
function
generatePasswordResetToken
()
{
$this
->
password_reset_token
=
Security
::
generateRandomKey
()
.
'_'
.
time
();
$this
->
password_reset_token
=
Yii
::
$app
->
getSecurity
()
->
generateRandomKey
()
.
'_'
.
time
();
}
/**
...
...
apps/advanced/common/tests/templates/fixtures/user.php
View file @
2bab6259
<?php
use
yii\helpers\Security
;
return
[
'username'
=>
'userName'
,
'auth_key'
=>
function
(
$fixture
,
$faker
,
$index
)
{
$fixture
[
'auth_key'
]
=
Security
::
generateRandomKey
();
$fixture
[
'auth_key'
]
=
Yii
::
$app
->
getSecurity
()
->
generateRandomKey
();
return
$fixture
;
},
'password_hash'
=>
function
(
$fixture
,
$faker
,
$index
)
{
$fixture
[
'password_hash'
]
=
Security
::
generatePasswordHash
(
'password_'
.
$index
);
$fixture
[
'password_hash'
]
=
Yii
::
$app
->
getSecurity
()
->
generatePasswordHash
(
'password_'
.
$index
);
return
$fixture
;
},
'password_reset_token'
=>
function
(
$fixture
,
$faker
,
$index
)
{
$fixture
[
'password_reset_token'
]
=
Security
::
generateRandomKey
()
.
'_'
.
time
();
$fixture
[
'password_reset_token'
]
=
Yii
::
$app
->
getSecurity
()
->
generateRandomKey
()
.
'_'
.
time
();
return
$fixture
;
},
...
...
framework/web/Request.php
View file @
2bab6259
...
...
@@ -9,7 +9,6 @@ namespace yii\web;
use
Yii
;
use
yii\base\InvalidConfigException
;
use
yii\helpers\Security
;
use
yii\helpers\StringHelper
;
/**
...
...
@@ -1188,7 +1187,7 @@ class Request extends \yii\base\Request
if
(
$this
->
enableCookieValidation
)
{
$key
=
$this
->
getCookieValidationKey
();
foreach
(
$_COOKIE
as
$name
=>
$value
)
{
if
(
is_string
(
$value
)
&&
(
$value
=
Security
::
validateData
(
$value
,
$key
))
!==
false
)
{
if
(
is_string
(
$value
)
&&
(
$value
=
Yii
::
$app
->
getSecurity
()
->
validateData
(
$value
,
$key
))
!==
false
)
{
$cookies
[
$name
]
=
new
Cookie
([
'name'
=>
$name
,
'value'
=>
@
unserialize
(
$value
),
...
...
@@ -1218,7 +1217,7 @@ class Request extends \yii\base\Request
public
function
getCookieValidationKey
()
{
if
(
$this
->
_cookieValidationKey
===
null
)
{
$this
->
_cookieValidationKey
=
Security
::
getSecretKey
(
__CLASS__
.
'/'
.
Yii
::
$app
->
id
);
$this
->
_cookieValidationKey
=
Yii
::
$app
->
getSecurity
()
->
getSecretKey
(
__CLASS__
.
'/'
.
Yii
::
$app
->
id
);
}
return
$this
->
_cookieValidationKey
;
...
...
@@ -1323,7 +1322,7 @@ class Request extends \yii\base\Request
{
$options
=
$this
->
csrfCookie
;
$options
[
'name'
]
=
$this
->
csrfParam
;
$options
[
'value'
]
=
Security
::
generateRandomKey
();
$options
[
'value'
]
=
Yii
::
$app
->
getSecurity
()
->
generateRandomKey
();
return
new
Cookie
(
$options
);
}
...
...
framework/web/Response.php
View file @
2bab6259
...
...
@@ -12,7 +12,6 @@ use yii\base\InvalidConfigException;
use
yii\base\InvalidParamException
;
use
yii\helpers\Url
;
use
yii\helpers\FileHelper
;
use
yii\helpers\Security
;
use
yii\helpers\StringHelper
;
/**
...
...
@@ -371,7 +370,7 @@ class Response extends \yii\base\Response
foreach
(
$this
->
getCookies
()
as
$cookie
)
{
$value
=
$cookie
->
value
;
if
(
$cookie
->
expire
!=
1
&&
isset
(
$validationKey
))
{
$value
=
Security
::
hashData
(
serialize
(
$value
),
$validationKey
);
$value
=
Yii
::
$app
->
getSecurity
()
->
hashData
(
serialize
(
$value
),
$validationKey
);
}
setcookie
(
$cookie
->
name
,
$value
,
$cookie
->
expire
,
$cookie
->
path
,
$cookie
->
domain
,
$cookie
->
secure
,
$cookie
->
httpOnly
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment