endpoints: remove /keys

BitTorrent support should now be able to use the keyserver
infrastructure instead.
This commit is contained in:
Jimmy Zelinskie 2016-04-11 18:22:47 -04:00 committed by Jimmy Zelinskie
parent 6a00025545
commit fca258d8bf

View file

@ -1,14 +1,11 @@
import json
import logging
from jwkest import long_to_base64
from cachetools import lru_cache
from cryptography.x509 import load_pem_x509_certificate
from cryptography.hazmat.backends import default_backend
from urlparse import urlparse
from flask import (abort, redirect, request, url_for, make_response, Response,
Blueprint, send_from_directory, jsonify, send_file)
from flask.ext.login import current_user
from urlparse import urlparse
import features
@ -30,7 +27,7 @@ from endpoints.common import (common_login, render_page_template, route_show_if,
from endpoints.csrf import csrf_protect, generate_csrf_token, verify_csrf
from endpoints.decorators import anon_protect, anon_allowed
from health.healthcheck import get_healthchecker
from util.cache import no_cache, cache_control
from util.cache import no_cache
from util.headers import parse_basic_auth
from util.invoice import renderInvoiceToPdf
from util.seo import render_snapshot
@ -688,24 +685,3 @@ def redirect_to_namespace(namespace):
return redirect(url_for('web.org_view', path=namespace))
else:
return redirect(url_for('web.user_view', path=namespace))
@lru_cache(maxsize=1)
def _load_certificate_bytes(certificate_file_path):
with open(certificate_file_path) as cert_file:
return load_pem_x509_certificate(cert_file.read(), default_backend()).public_key()
@route_show_if(features.BITTORRENT)
@cache_control(max_age=300)
@web.route('/keys', methods=['GET'])
def jwk_set_uri():
certificate = _load_certificate_bytes(app.config['JWT_AUTH_CERTIFICATE_PATH'])
return jsonify({
'keys': [{
'kty': 'RSA',
'alg': 'RS256',
'use': 'sig',
'n': long_to_base64(certificate.public_numbers().n),
'e': long_to_base64(certificate.public_numbers().e),
}],
'issuer': JWT_ISSUER,
})