]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/Diaspora/DiasporaPlugin.php
Include the Diaspora GUID string in our XRD metadata
[quix0rs-gnu-social.git] / plugins / Diaspora / DiasporaPlugin.php
index 1490fce7a31ca9d5d0607f2fde5311cfe8a7d264..66a9759f8787078d984914a803c29a9653c9ec74 100644 (file)
@@ -38,8 +38,16 @@ class DiasporaPlugin extends Plugin
 
     public function onEndAttachPubkeyToUserXRD(Magicsig $magicsig, XML_XRD $xrd, Profile $target)
     {
+        // So far we've only handled RSA keys, but it can change in the future,
+        // so be prepared. And remember to change the statically assigned type attribute below!
+        assert($magicsig->publicKey instanceof Crypt_RSA);
         $xrd->links[] = new XML_XRD_Element_Link(self::REL_PUBLIC_KEY,
-                                    base64_encode($magicsig->exportPublicKey()));
+                                    base64_encode($magicsig->exportPublicKey()), 'RSA');
+
+        // Instead of choosing a random string, we calculate our GUID from the public key
+        // by fingerprint through a sha256 hash.
+        $xrd->links[] = new XML_XRD_Element_Link(self::REL_GUID,
+                                    strtolower($magicsig->toFingerprint()));
     }
 
     public function onPluginVersion(array &$versions)