Added *very preliminary* support for webfinger
This commit is contained in:
parent
31f5c4567f
commit
9c1c6c2a61
@ -21,6 +21,8 @@ from mediagoblin.submit.routing import submit_routes
|
|||||||
from mediagoblin.user_pages.routing import user_routes
|
from mediagoblin.user_pages.routing import user_routes
|
||||||
from mediagoblin.edit.routing import edit_routes
|
from mediagoblin.edit.routing import edit_routes
|
||||||
from mediagoblin.listings.routing import tag_routes
|
from mediagoblin.listings.routing import tag_routes
|
||||||
|
from mediagoblin.webfinger.routing import webfinger_well_known_routes, \
|
||||||
|
webfinger_routes
|
||||||
|
|
||||||
|
|
||||||
def get_mapper():
|
def get_mapper():
|
||||||
@ -36,5 +38,7 @@ def get_mapper():
|
|||||||
mapping.extend(user_routes, '/u')
|
mapping.extend(user_routes, '/u')
|
||||||
mapping.extend(edit_routes, '/edit')
|
mapping.extend(edit_routes, '/edit')
|
||||||
mapping.extend(tag_routes, '/tag')
|
mapping.extend(tag_routes, '/tag')
|
||||||
|
mapping.extend(webfinger_well_known_routes, '/.well-known')
|
||||||
|
mapping.extend(webfinger_routes, '/api/webfinger')
|
||||||
|
|
||||||
return mapping
|
return mapping
|
||||||
|
27
mediagoblin/templates/mediagoblin/webfinger/host-meta.xml
Normal file
27
mediagoblin/templates/mediagoblin/webfinger/host-meta.xml
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
{# GNU MediaGoblin -- federated, autonomous media hosting
|
||||||
|
# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-#}
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'
|
||||||
|
xmlns:hm='http://host-meta.net/xrd/1.0'>
|
||||||
|
|
||||||
|
<hm:Host>{{ request.host }}</hm:Host>
|
||||||
|
|
||||||
|
<Link rel='lrdd'
|
||||||
|
template='{{ lrdd_template }}'>
|
||||||
|
<Title>{{ llrd_title }}</Title>
|
||||||
|
</Link>
|
||||||
|
</XRD>
|
26
mediagoblin/templates/mediagoblin/webfinger/xrd.xml
Normal file
26
mediagoblin/templates/mediagoblin/webfinger/xrd.xml
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
{# GNU MediaGoblin -- federated, autonomous media hosting
|
||||||
|
# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
-#}
|
||||||
|
<?xml version='1.0' encoding='UTF-8'?>
|
||||||
|
<XRD xmlns='http://docs.oasis-open.org/ns/xri/xrd-1.0'>
|
||||||
|
|
||||||
|
<Subject>{{ uri }}</Subject>
|
||||||
|
<Alias>http://{{ request.host }}/u/{{ username }}</Alias>
|
||||||
|
|
||||||
|
<Link rel="http://schemas.google.com/g/2010#updates-from"
|
||||||
|
type="application/atom+xml"
|
||||||
|
href="http://{{ request.host }}/u/{{ username }}/atom/" />
|
||||||
|
</XRD>
|
15
mediagoblin/webfinger/__init__.py
Normal file
15
mediagoblin/webfinger/__init__.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# GNU MediaGoblin -- federated, autonomous media hosting
|
||||||
|
# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
25
mediagoblin/webfinger/routing.py
Normal file
25
mediagoblin/webfinger/routing.py
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
# GNU MediaGoblin -- federated, autonomous media hosting
|
||||||
|
# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
from routes.route import Route
|
||||||
|
|
||||||
|
webfinger_well_known_routes = [
|
||||||
|
Route('mediagoblin.webfinger.host_meta', '/host-meta',
|
||||||
|
controller='mediagoblin.webfinger.views:host_meta')]
|
||||||
|
|
||||||
|
webfinger_routes = [
|
||||||
|
Route('mediagoblin.webfinger.xrd', '/xrd',
|
||||||
|
controller='mediagoblin.webfinger.views:xrd')]
|
46
mediagoblin/webfinger/views.py
Normal file
46
mediagoblin/webfinger/views.py
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
# GNU MediaGoblin -- federated, autonomous media hosting
|
||||||
|
# Copyright (C) 2011 MediaGoblin contributors. See AUTHORS.
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU Affero General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program is distributed in the hope that it will be useful,
|
||||||
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
# GNU Affero General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU Affero General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import re
|
||||||
|
import mediagoblin.mg_globals as mg_globals
|
||||||
|
|
||||||
|
from mediagoblin.tools.response import render_to_response
|
||||||
|
|
||||||
|
LRDD_TEMPLATE = '{protocol}://{host}/api/webfinger/xrd?uri={{uri}}'
|
||||||
|
|
||||||
|
def host_meta(request):
|
||||||
|
'''
|
||||||
|
Webfinger host-meta
|
||||||
|
'''
|
||||||
|
return render_to_response(
|
||||||
|
request,
|
||||||
|
'mediagoblin/webfinger/host-meta.xml',
|
||||||
|
{'request': request,
|
||||||
|
'lrdd_template': LRDD_TEMPLATE.format(
|
||||||
|
protocol='http',
|
||||||
|
host=request.host)})
|
||||||
|
|
||||||
|
def xrd(request):
|
||||||
|
'''
|
||||||
|
Find user data based on a webfinger URI
|
||||||
|
'''
|
||||||
|
return render_to_response(
|
||||||
|
request,
|
||||||
|
'mediagoblin/webfinger/xrd.xml',
|
||||||
|
{'request': request,
|
||||||
|
'username': re.search(
|
||||||
|
r'^acct:([^@]*)',
|
||||||
|
request.GET.get('uri')).group(1)})
|
Loading…
x
Reference in New Issue
Block a user