forked from GNUsocial/gnu-social
Only use a Profile in MagicEnvelope keypair retrieval
So we _know_ there is a profile for the submitter we're about to verify.
This commit is contained in:
parent
56194b3cd9
commit
d44588f98b
@ -69,11 +69,7 @@ class MagicEnvelope
|
|||||||
public function getKeyPair(Profile $profile, $discovery=false) {
|
public function getKeyPair(Profile $profile, $discovery=false) {
|
||||||
$magicsig = Magicsig::getKV('user_id', $profile->id);
|
$magicsig = Magicsig::getKV('user_id', $profile->id);
|
||||||
if ($discovery && !$magicsig instanceof Magicsig) {
|
if ($discovery && !$magicsig instanceof Magicsig) {
|
||||||
$signer_uri = $profile->getUri();
|
$magicsig = $this->discoverKeyPair($profile);
|
||||||
if (empty($signer_uri)) {
|
|
||||||
throw new ServerException(sprintf('Profile missing URI (id==%d)', $profile->id));
|
|
||||||
}
|
|
||||||
$magicsig = $this->discoverKeyPair($signer_uri);
|
|
||||||
// discoverKeyPair should've thrown exception if it failed
|
// discoverKeyPair should've thrown exception if it failed
|
||||||
assert($magicsig instanceof Magicsig);
|
assert($magicsig instanceof Magicsig);
|
||||||
} elseif (!$magicsig instanceof Magicsig) { // No discovery request, so we'll give up.
|
} elseif (!$magicsig instanceof Magicsig) { // No discovery request, so we'll give up.
|
||||||
@ -87,8 +83,13 @@ class MagicEnvelope
|
|||||||
*
|
*
|
||||||
* @return Magicsig with loaded keypair
|
* @return Magicsig with loaded keypair
|
||||||
*/
|
*/
|
||||||
public function discoverKeyPair($signer_uri)
|
public function discoverKeyPair(Profile $profile)
|
||||||
{
|
{
|
||||||
|
$signer_uri = $profile->getUri();
|
||||||
|
if (empty($signer_uri)) {
|
||||||
|
throw new ServerException(sprintf('Profile missing URI (id==%d)', $profile->id));
|
||||||
|
}
|
||||||
|
|
||||||
$disco = new Discovery();
|
$disco = new Discovery();
|
||||||
|
|
||||||
// Throws exception on lookup problems
|
// Throws exception on lookup problems
|
||||||
@ -269,12 +270,7 @@ class MagicEnvelope
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ($profile instanceof Profile) {
|
|
||||||
$magicsig = $this->getKeyPair($profile, true); // Do discovery too if necessary
|
$magicsig = $this->getKeyPair($profile, true); // Do discovery too if necessary
|
||||||
} else {
|
|
||||||
$signer_uri = $this->getAuthorUri();
|
|
||||||
$magicsig = $this->discoverKeyPair($signer_uri);
|
|
||||||
}
|
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
common_log(LOG_DEBUG, "Salmon error: ".$e->getMessage());
|
common_log(LOG_DEBUG, "Salmon error: ".$e->getMessage());
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
Reference in New Issue
Block a user