torrent: remove pubkey token header

This commit is contained in:
Jimmy Zelinskie 2016-01-08 14:29:24 -05:00
parent 7d67fd2c86
commit 932d892276

View file

@ -2,9 +2,6 @@ import time
import hashlib
import urllib
from cryptography.x509 import load_pem_x509_certificate
from cryptography.hazmat.backends import default_backend
import bencode
import resumablehashlib
import jwt
@ -20,11 +17,6 @@ REGISTRY_TITLE = app.config.get('REGISTRY_TITLE')
JWT_ISSUER = app.config.get('JWT_AUTH_TOKEN_ISSUER')
@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()
@lru_cache(maxsize=1)
def _load_private_key(private_key_file_path):
with open(private_key_file_path) as private_key_file:
@ -37,13 +29,8 @@ def _torrent_jwt(info_dict):
'infohash': _infohash(info_dict),
}
certificate = _load_certificate_bytes(app.config['JWT_AUTH_CERTIFICATE_PATH'])
token_headers = {
'x5c': [certificate],
}
private_key = _load_private_key(app.config['JWT_AUTH_PRIVATE_KEY_PATH'])
return jwt.encode(token_data, private_key, 'RS256', headers=token_headers)
return jwt.encode(token_data, private_key, 'RS256')
def _infohash(infodict):
digest = hashlib.sha1()