mirror of
https://github.com/friendica/friendica
synced 2025-01-11 03:24:46 +00:00
Merge pull request #13614 from HankG/oauth-redirect-fix
Fix OAuth Redirect Url Scrubbing
This commit is contained in:
commit
9d93eaf810
2 changed files with 3 additions and 4 deletions
|
@ -90,10 +90,10 @@ class Token extends BaseApi
|
||||||
$me = null;
|
$me = null;
|
||||||
} elseif ($request['grant_type'] == 'authorization_code') {
|
} elseif ($request['grant_type'] == 'authorization_code') {
|
||||||
// For security reasons only allow freshly created tokens
|
// For security reasons only allow freshly created tokens
|
||||||
$uri = new Uri($request['redirect_uri']);
|
$redirect_uri = strtok($request['redirect_uri'],'?');
|
||||||
$condition = [
|
$condition = [
|
||||||
"`redirect_uri` LIKE ? AND `id` = ? AND `code` = ? AND `created_at` > ?",
|
"`redirect_uri` LIKE ? AND `id` = ? AND `code` = ? AND `created_at` > ?",
|
||||||
'%' . $uri->getScheme() . '://' . $uri->getHost() . $uri->getPath() . '%', $application['id'], $request['code'], DateTimeFormat::utc('now - 5 minutes')
|
$redirect_uri, $application['id'], $request['code'], DateTimeFormat::utc('now - 5 minutes')
|
||||||
];
|
];
|
||||||
|
|
||||||
$token = DBA::selectFirst('application-view', ['access_token', 'created_at', 'uid'], $condition);
|
$token = DBA::selectFirst('application-view', ['access_token', 'created_at', 'uid'], $condition);
|
||||||
|
|
|
@ -131,8 +131,7 @@ class OAuth
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($redirect_uri)) {
|
if (!empty($redirect_uri)) {
|
||||||
$uri = new Uri($redirect_uri);
|
$redirect_uri = strtok($redirect_uri, '?');
|
||||||
$redirect_uri = $uri->getScheme() . '://' . $uri->getHost() . $uri->getPath();
|
|
||||||
$condition = DBA::mergeConditions($condition, ["`redirect_uri` LIKE ?", '%' . $redirect_uri . '%']);
|
$condition = DBA::mergeConditions($condition, ["`redirect_uri` LIKE ?", '%' . $redirect_uri . '%']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue