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
f09c78aa
Commit
f09c78aa
authored
Nov 08, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
save security keys as a serialized string instead of exported variable.
parent
4b49a31f
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
6 deletions
+6
-6
console.php
apps/basic/config/console.php
+1
-1
web.php
apps/basic/config/web.php
+1
-1
BaseSecurity.php
framework/yii/helpers/BaseSecurity.php
+4
-4
No files found.
apps/basic/config/console.php
View file @
f09c78aa
<?php
$params
=
require
(
__DIR__
.
'/params.php'
);
return
[
'id'
=>
'b
ootstrap
-console'
,
'id'
=>
'b
asic
-console'
,
'basePath'
=>
dirname
(
__DIR__
),
'preload'
=>
[
'log'
],
'controllerPath'
=>
dirname
(
__DIR__
)
.
'/commands'
,
...
...
apps/basic/config/web.php
View file @
f09c78aa
<?php
$params
=
require
(
__DIR__
.
'/params.php'
);
$config
=
[
'id'
=>
'b
ootstrap
'
,
'id'
=>
'b
asic
'
,
'basePath'
=>
dirname
(
__DIR__
),
'extensions'
=>
require
(
__DIR__
.
'/../vendor/yiisoft/extensions.php'
),
'components'
=>
[
...
...
framework/yii/helpers/BaseSecurity.php
View file @
f09c78aa
...
...
@@ -175,7 +175,7 @@ class BaseSecurity
/**
* Returns a secret key associated with the specified name.
* If the secret key does not exist, a random key will be generated
* and saved in the file "keys.
php
" under the application's runtime directory
* and saved in the file "keys.
data
" under the application's runtime directory
* so that the same secret key can be returned in future requests.
* @param string $name the name that is associated with the secret key
* @param integer $length the length of the key that should be generated if not exists
...
...
@@ -184,16 +184,16 @@ class BaseSecurity
public
static
function
getSecretKey
(
$name
,
$length
=
32
)
{
static
$keys
;
$keyFile
=
Yii
::
$app
->
getRuntimePath
()
.
'/keys.
php
'
;
$keyFile
=
Yii
::
$app
->
getRuntimePath
()
.
'/keys.
data
'
;
if
(
$keys
===
null
)
{
$keys
=
[];
if
(
is_file
(
$keyFile
))
{
$keys
=
require
(
$keyFile
);
$keys
=
unserialize
(
file_get_contents
(
$keyFile
)
);
}
}
if
(
!
isset
(
$keys
[
$name
]))
{
$keys
[
$name
]
=
static
::
generateRandomKey
(
$length
);
file_put_contents
(
$keyFile
,
"<?php
\n
return "
.
var_export
(
$keys
,
true
)
.
";
\n
"
);
file_put_contents
(
$keyFile
,
serialize
(
$keys
)
);
}
return
$keys
[
$name
];
}
...
...
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