summaryrefslogtreecommitdiff
path: root/plugins/OStatus/lib/salmonaction.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-02-27 17:07:57 -0500
committerEvan Prodromou <evan@status.net>2010-02-27 17:07:57 -0500
commitf00e8bbf47e3ea93578c5bfaba8d1d0460526086 (patch)
treec60faae494a2e43bdf45e7508c4ac2bd763399b5 /plugins/OStatus/lib/salmonaction.php
parentb701f5648d944cbb74748c48ea399b226eafc525 (diff)
parent04c4facba9230f40726c5891dcac21d928fbb2ab (diff)
Merge branch 'testing' into 0.9.x
Diffstat (limited to 'plugins/OStatus/lib/salmonaction.php')
-rw-r--r--plugins/OStatus/lib/salmonaction.php27
1 files changed, 15 insertions, 12 deletions
diff --git a/plugins/OStatus/lib/salmonaction.php b/plugins/OStatus/lib/salmonaction.php
index a03169101..fa9dc3b1d 100644
--- a/plugins/OStatus/lib/salmonaction.php
+++ b/plugins/OStatus/lib/salmonaction.php
@@ -41,29 +41,32 @@ class SalmonAction extends Action
$this->clientError(_m('This method requires a POST.'));
}
- if (empty($_SERVER['CONTENT_TYPE']) || $_SERVER['CONTENT_TYPE'] != 'application/atom+xml') {
- $this->clientError(_m('Salmon requires application/atom+xml'));
+ if (empty($_SERVER['CONTENT_TYPE']) || $_SERVER['CONTENT_TYPE'] != 'application/magic-envelope+xml') {
+ $this->clientError(_m('Salmon requires application/magic-envelope+xml'));
}
$xml = file_get_contents('php://input');
- $dom = DOMDocument::loadXML($xml);
+ // Check the signature
+ $salmon = new Salmon;
+ if (!$salmon->verifyMagicEnv($xml)) {
+ common_log(LOG_DEBUG, "Salmon signature verification failed.");
+ $this->clientError(_m('Salmon signature verification failed.'));
+ } else {
+ $magic_env = new MagicEnvelope();
+ $env = $magic_env->parse($xml);
+ $xml = $magic_env->unfold($env);
+ }
+
+
+ $dom = DOMDocument::loadXML($xml);
if ($dom->documentElement->namespaceURI != Activity::ATOM ||
$dom->documentElement->localName != 'entry') {
common_log(LOG_DEBUG, "Got invalid Salmon post: $xml");
$this->clientError(_m('Salmon post must be an Atom entry.'));
}
- // Check the signature
- $salmon = new Salmon;
- if (!common_config('ostatus', 'skip_signatures')) {
- if (!$salmon->verifyMagicEnv($dom)) {
- common_log(LOG_DEBUG, "Salmon signature verification failed.");
- $this->clientError(_m('Salmon signature verification failed.'));
- }
- }
-
$this->act = new Activity($dom->documentElement);
return true;
}