Skip to content

Commit d36ca9a

Browse files
committed
Improve the wrapping of the Phorum URL arguments, to make the redirect from
an openid provider work.
1 parent 26ac3aa commit d36ca9a

File tree

2 files changed

+38
-8
lines changed

2 files changed

+38
-8
lines changed

login_custom_action/openid/action/complete.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,17 @@
1919
// Check if the authentication failed.
2020
if ($response->status == Auth_OpenID_FAILURE) {
2121
$data['error'] = $lang['ErrFailed'];
22+
23+
if (function_exists('event_logging_writelog')) {
24+
event_logging_writelog(array(
25+
"source" => "social_authentication",
26+
"message" => "OpenID authentication failed",
27+
"details" => "OpenID message: " . $response->message,
28+
"loglevel" => EVENTLOG_LVL_INFO,
29+
"category" => EVENTLOG_CAT_MODULE
30+
));
31+
}
32+
2233
return;
2334
}
2435

social_authentication.php

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ function phorum_mod_social_authentication_url_build(
5454
in_array('_sas=complete', $query_params, TRUE))
5555
{
5656
$wrapped = '_saw=' .
57-
urlencode(implode(",", $query_params));
57+
base64_encode(implode(",", $query_params));
5858
$url = phorum_api_url(PHORUM_LOGIN_ACTION_URL, $wrapped);
5959
}
6060

@@ -70,16 +70,35 @@ function phorum_mod_social_authentication_parse_request()
7070
{
7171
global $PHORUM;
7272

73-
// Backup the query string for the OpenID modules, which access the
74-
// query string directly.
75-
$PHORUM['MOD_SOCIAL_AUTHENTICATION_QUERY_STRING'] =
76-
isset($_SERVER['QUERY_STRING']) ? $_SERVER['QUERY_STRING'] : '';
77-
7873
// Fix the query string for Phorum use.
74+
$query = $_SERVER['QUERY_STRING'];
7975
if (isset($_GET['_saw'])) {
80-
$_SERVER['QUERY_STRING'] =
81-
urldecode($_GET['_saw']);
76+
$_SERVER['QUERY_STRING'] = base64_decode($_GET['_saw']);
77+
unset($_GET['_saw']);
78+
}
79+
80+
// Prepare the query string for the OpenID modules, which access the
81+
// query string directly.
82+
$params = array();
83+
if (trim($query) !== '')
84+
{
85+
$parts = explode("&", $query);
86+
foreach ($parts as $part) {
87+
$parts = explode("=", $part, 2);
88+
if (count($parts) != 2) {
89+
continue;
90+
}
91+
list($k, $v) = $parts;
92+
if ($k == '_saw') continue;
93+
$params[urldecode($k)] = urldecode($v);
94+
}
95+
}
96+
97+
$parts = array();
98+
foreach ($params as $k => $v) {
99+
$parts[] = urlencode($k) . '=' . urlencode($v);
82100
}
101+
$PHORUM['MOD_SOCIAL_AUTHENTICATION_QUERY_STRING'] = implode("&", $parts);
83102
}
84103

85104
/**

0 commit comments

Comments
 (0)