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
3acca93a
Commit
3acca93a
authored
Sep 20, 2013
by
Qiang Xue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable CSRF validation by default.
parent
41f7a7d2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
8 additions
and
2 deletions
+8
-2
yii.js
framework/yii/assets/yii.js
+6
-0
Request.php
framework/yii/web/Request.php
+2
-2
No files found.
framework/yii/assets/yii.js
View file @
3acca93a
...
@@ -163,6 +163,12 @@ yii = (function ($) {
...
@@ -163,6 +163,12 @@ yii = (function ($) {
init
:
function
()
{
init
:
function
()
{
var
$document
=
$
(
document
);
var
$document
=
$
(
document
);
$
.
ajaxPrefilter
(
function
(
options
,
originalOptions
,
xhr
)
{
if
(
!
options
.
crossDomain
&&
pub
.
getCsrfVar
())
{
xhr
.
setRequestHeader
(
'X-CSRF-TOKEN'
,
pub
.
getCsrfToken
());
}
});
$document
.
on
(
'click.yii'
,
pub
.
clickableSelector
,
function
(
event
)
{
$document
.
on
(
'click.yii'
,
pub
.
clickableSelector
,
function
(
event
)
{
var
$this
=
$
(
this
);
var
$this
=
$
(
this
);
if
(
pub
.
allowAction
(
$this
))
{
if
(
pub
.
allowAction
(
$this
))
{
...
...
framework/yii/web/Request.php
View file @
3acca93a
...
@@ -76,7 +76,7 @@ class Request extends \yii\base\Request
...
@@ -76,7 +76,7 @@ class Request extends \yii\base\Request
const
CSRF_HEADER
=
'X-CSRF-TOKEN'
;
const
CSRF_HEADER
=
'X-CSRF-TOKEN'
;
/**
/**
* @var boolean whether to enable CSRF (Cross-Site Request Forgery) validation. Defaults to
fals
e.
* @var boolean whether to enable CSRF (Cross-Site Request Forgery) validation. Defaults to
tru
e.
* When CSRF validation is enabled, forms submitted to an Yii Web application must be originated
* When CSRF validation is enabled, forms submitted to an Yii Web application must be originated
* from the same application. If not, a 400 HTTP exception will be raised.
* from the same application. If not, a 400 HTTP exception will be raised.
*
*
...
@@ -90,7 +90,7 @@ class Request extends \yii\base\Request
...
@@ -90,7 +90,7 @@ class Request extends \yii\base\Request
* @see Controller::enableCsrfValidation
* @see Controller::enableCsrfValidation
* @see http://en.wikipedia.org/wiki/Cross-site_request_forgery
* @see http://en.wikipedia.org/wiki/Cross-site_request_forgery
*/
*/
public
$enableCsrfValidation
=
fals
e
;
public
$enableCsrfValidation
=
tru
e
;
/**
/**
* @var string the name of the token used to prevent CSRF. Defaults to '_csrf'.
* @var string the name of the token used to prevent CSRF. Defaults to '_csrf'.
* This property is used only when [[enableCsrfValidation]] is true.
* This property is used only when [[enableCsrfValidation]] is true.
...
...
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