summaryrefslogtreecommitdiff
path: root/actions/openidlogin.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-08-28 23:59:34 -0400
committerEvan Prodromou <evan@prodromou.name>2008-08-28 23:59:34 -0400
commit42a6492152a85124d8832b75ee05be3906a98d55 (patch)
treee94b87a5cdf4ffb9b23e6dc111127a63da9dcfbc /actions/openidlogin.php
parentd6dd35a66a394a830eb171ab6620da808667c772 (diff)
CSRF protection for OpenID form
darcs-hash:20080829035934-84dde-cf36fd802bed76fdf15ac39b838494a414d5cc1e.gz
Diffstat (limited to 'actions/openidlogin.php')
-rw-r--r--actions/openidlogin.php8
1 files changed, 8 insertions, 0 deletions
diff --git a/actions/openidlogin.php b/actions/openidlogin.php
index 874ef81b2..136421cb0 100644
--- a/actions/openidlogin.php
+++ b/actions/openidlogin.php
@@ -28,6 +28,13 @@ class OpenidloginAction extends Action {
if (common_logged_in()) {
common_user_error(_('Already logged in.'));
} else if ($_SERVER['REQUEST_METHOD'] == 'POST') {
+ # CSRF protection
+ $token = $this->trimmed('token');
+ if (!$token || $token != common_session_token()) {
+ $this->show_form(_('There was a problem with your session token. Try again, please.'));
+ return;
+ }
+
$openid_url = $this->trimmed('openid_url');
$result = oid_authenticate($openid_url,
'finishopenidlogin');
@@ -62,6 +69,7 @@ class OpenidloginAction extends Action {
common_element_start('form', array('method' => 'post',
'id' => 'openidlogin',
'action' => $formaction));
+ common_hidden('token', common_session_token());
common_input('openid_url', _('OpenID URL'),
$openid_url,
_('Your OpenID URL'));