Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
UNL Information Services
NMC-PHP-Framework
Commits
0aa8124e
Commit
0aa8124e
authored
Dec 12, 2011
by
Tim Steiner
Browse files
Ignore the IP Address check from the XSRF token and add a user agent check.
parent
1142b8c7
Changes
1
Hide whitespace changes
Inline
Side-by-side
library/Unl/XsrfToken.php
View file @
0aa8124e
...
...
@@ -59,7 +59,8 @@ class Unl_XsrfToken
$token
=
array
(
'expires'
=>
$expires
,
'formUrl'
=>
$_SERVER
[
'SCRIPT_URI'
],
'remoteAddress'
=>
$_SERVER
[
'REMOTE_ADDR'
]
'remoteAddress'
=>
$_SERVER
[
'REMOTE_ADDR'
],
'userAgent'
=>
$_SERVER
[
'HTTP_USER_AGENT'
],
);
$tokenId
=
base64_encode
(
hash
(
'sha256'
,
microtime
(
TRUE
),
TRUE
));
$this
->
_session
->
tokens
[
$tokenId
]
=
$token
;
...
...
@@ -87,13 +88,17 @@ class Unl_XsrfToken
return
FALSE
;
}
if
(
$token
[
'remoteAddress'
]
!=
$_SERVER
[
'REMOTE_ADDR'
])
{
$log
->
log
(
'XSRF: Remote address changed.'
,
Zend_Log
::
ERR
);
return
FALSE
;
$log
->
log
(
'XSRF: Remote address changed.
(ignoring)
'
,
Zend_Log
::
ERR
);
//
return FALSE;
}
if
(
$token
[
'formUrl'
]
!=
$_SERVER
[
'HTTP_REFERER'
])
{
$log
->
log
(
'XSRF: Referer doesn\'t match form url.'
,
Zend_Log
::
ERR
);
return
FALSE
;
}
if
(
$token
[
'userAgent'
]
!=
$_SERVER
[
'HTTP_USER_AGENT'
])
{
$log
->
log
(
'XSRF: User agent has changed.'
,
Zend_Log
::
ERR
);
return
FALSE
;
}
if
(
$onceOnly
)
{
unset
(
$this
->
_session
->
tokens
[
$tokenId
]);
...
...
Write
Preview
Supports
Markdown
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