-
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove magic public key on webfinger
- Loading branch information
Bob Mottram
committed
Feb 4, 2021
1 parent
d6f7ad2
commit 22b9462
Showing
1 changed file
with
0 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,13 +6,6 @@ | |
__email__ = "[email protected]" | ||
__status__ = "Production" | ||
|
||
import base64 | ||
try: | ||
from Cryptodome.PublicKey import RSA | ||
from Cryptodome.Util import number | ||
except ImportError: | ||
from Crypto.PublicKey import RSA | ||
from Crypto.Util import number | ||
import os | ||
import urllib.parse | ||
from session import getJson | ||
|
@@ -97,19 +90,6 @@ def webfingerHandle(session, handle: str, httpPrefix: str, | |
return result | ||
|
||
|
||
def _generateMagicKey(publicKeyPem) -> str: | ||
"""See magic_key method in | ||
https://github.com/tootsuite/mastodon/blob/ | ||
707ddf7808f90e3ab042d7642d368c2ce8e95e6f/app/models/account.rb | ||
""" | ||
privkey = RSA.importKey(publicKeyPem) | ||
modBytes = number.long_to_bytes(privkey.n) | ||
mod = base64.urlsafe_b64encode(modBytes).decode("utf-8") | ||
expBytes = number.long_to_bytes(privkey.e) | ||
pubexp = base64.urlsafe_b64encode(expBytes).decode("utf-8") | ||
return f"data:application/magic-public-key,RSA.{mod}.{pubexp}" | ||
|
||
|
||
def storeWebfingerEndpoint(nickname: str, domain: str, port: int, | ||
baseDir: str, wfJson: {}) -> bool: | ||
"""Stores webfinger endpoint for a user to a file | ||
|
@@ -168,10 +148,6 @@ def createWebfingerEndpoint(nickname: str, domain: str, port: int, | |
"href": personId, | ||
"rel": "self", | ||
"type": "application/activity+json" | ||
}, | ||
{ | ||
"href": _generateMagicKey(publicKeyPem), | ||
"rel": "magic-public-key" | ||
} | ||
], | ||
"subject": subjectStr | ||
|