kopia lustrzana https://github.com/snarfed/bridgy-fed
start on webfinger
rodzic
9c73e756c0
commit
6ddd1d66d9
|
@ -22,8 +22,6 @@ CONNEG_HEADER = {
|
|||
'Accept': '%s; q=0.9, %s; q=0.8' % (CONTENT_TYPE_AS2, CONTENT_TYPE_AS),
|
||||
}
|
||||
|
||||
DOMAIN_RE = r'([^/]+\.[^/]+)'
|
||||
|
||||
|
||||
class ActorHandler(webapp2.RequestHandler):
|
||||
"""Serves /[DOMAIN], fetches its mf2, converts to AS Actor, and serves it."""
|
||||
|
@ -87,6 +85,6 @@ class InboxHandler(webapp2.RequestHandler):
|
|||
|
||||
|
||||
app = webapp2.WSGIApplication([
|
||||
(r'/%s/?' % DOMAIN_RE, ActorHandler),
|
||||
(r'/%s/inbox' % DOMAIN_RE, InboxHandler),
|
||||
(r'/%s/?' % common.DOMAIN_RE, ActorHandler),
|
||||
(r'/%s/inbox' % common.DOMAIN_RE, InboxHandler),
|
||||
], debug=appengine_config.DEBUG)
|
||||
|
|
|
@ -6,7 +6,7 @@ import logging
|
|||
import requests
|
||||
from webob import exc
|
||||
|
||||
|
||||
DOMAIN_RE = r'([^/]+\.[^/]+)'
|
||||
HEADERS = {
|
||||
'User-Agent': 'Bridgy Fed (https://fed.brid.gy/)',
|
||||
}
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{"links": [
|
||||
{
|
||||
"rel": "lrdd",
|
||||
"type": "application/json",
|
||||
"template": "https://{{ host }}/{uri}&format=json"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version='1.0' encoding='UTF-8'?>
|
||||
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
|
||||
<Link rel='lrdd' type='application/xrd+xml' template='https://{{ host }}/{uri}' />
|
||||
</XRD>
|
|
@ -0,0 +1,10 @@
|
|||
<XRDS xmlns="xri://$xrds">
|
||||
<XRD xmlns:simple="http://xrds-simple.net/core/1.0"
|
||||
xmlns="xri://$XRD*($v*2.0)" version="2.0">
|
||||
<Type>xri://$xrds*simple</Type>
|
||||
<Service>
|
||||
<Type>http://portablecontacts.net/spec/1.0</Type>
|
||||
<URI>https://{{ host }}/{uri}</URI>
|
||||
</Service>
|
||||
</XRD>
|
||||
</XRDS>
|
|
@ -0,0 +1,39 @@
|
|||
# coding=utf-8
|
||||
"""Unit tests for webfinger.py.
|
||||
|
||||
TODO: test error handling
|
||||
"""
|
||||
import json
|
||||
import unittest
|
||||
import urllib
|
||||
|
||||
import mock
|
||||
import requests
|
||||
|
||||
import webfinger
|
||||
from webfinger import app
|
||||
import common
|
||||
|
||||
|
||||
class WebFingerTest(unittest.TestCase):
|
||||
|
||||
def test_host_meta_handler_xrd(self):
|
||||
got = app.get_response('/.well-known/host-meta')
|
||||
self.assertEquals(200, got.status_int)
|
||||
self.assertEquals('application/xrd+xml; charset=utf-8',
|
||||
got.headers['Content-Type'])
|
||||
self.assertTrue(got.body.startswith('<?xml'), got.body)
|
||||
|
||||
def test_host_meta_handler_xrds(self):
|
||||
got = app.get_response('/.well-known/host-meta.xrds')
|
||||
self.assertEquals(200, got.status_int)
|
||||
self.assertEquals('application/xrds+xml; charset=utf-8',
|
||||
got.headers['Content-Type'])
|
||||
self.assertTrue(got.body.startswith('<XRDS'), got.body)
|
||||
|
||||
def test_host_meta_handler_jrd(self):
|
||||
got = app.get_response('/.well-known/host-meta.json')
|
||||
self.assertEquals(200, got.status_int)
|
||||
self.assertEquals('application/json; charset=utf-8',
|
||||
got.headers['Content-Type'])
|
||||
self.assertTrue(got.body.startswith('{'), got.body)
|
|
@ -0,0 +1,30 @@
|
|||
"""Handles requests for WebFinger endpoints.
|
||||
|
||||
https://webfinger.net/
|
||||
|
||||
Largely based on webfinger-unofficial/user.py.
|
||||
"""
|
||||
import json
|
||||
import logging
|
||||
|
||||
import appengine_config
|
||||
|
||||
from granary import microformats2
|
||||
import mf2py
|
||||
import mf2util
|
||||
from oauth_dropins.webutil import handlers, util
|
||||
import webapp2
|
||||
|
||||
import common
|
||||
|
||||
|
||||
class UserHandler(webapp2.RequestHandler):
|
||||
"""TODO"""
|
||||
|
||||
def get(self, username, domain):
|
||||
pass
|
||||
|
||||
|
||||
app = webapp2.WSGIApplication([
|
||||
(r'/(?:acct)?([^@/])@%s/?' % common.DOMAIN_RE, UserHandler),
|
||||
] + handlers.HOST_META_ROUTES, debug=appengine_config.DEBUG)
|
Ładowanie…
Reference in New Issue