torrent: remove pubkey token header
This commit is contained in:
parent
7d67fd2c86
commit
932d892276
1 changed files with 1 additions and 14 deletions
|
@ -2,9 +2,6 @@ import time
|
||||||
import hashlib
|
import hashlib
|
||||||
import urllib
|
import urllib
|
||||||
|
|
||||||
from cryptography.x509 import load_pem_x509_certificate
|
|
||||||
from cryptography.hazmat.backends import default_backend
|
|
||||||
|
|
||||||
import bencode
|
import bencode
|
||||||
import resumablehashlib
|
import resumablehashlib
|
||||||
import jwt
|
import jwt
|
||||||
|
@ -20,11 +17,6 @@ REGISTRY_TITLE = app.config.get('REGISTRY_TITLE')
|
||||||
JWT_ISSUER = app.config.get('JWT_AUTH_TOKEN_ISSUER')
|
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)
|
@lru_cache(maxsize=1)
|
||||||
def _load_private_key(private_key_file_path):
|
def _load_private_key(private_key_file_path):
|
||||||
with open(private_key_file_path) as private_key_file:
|
with open(private_key_file_path) as private_key_file:
|
||||||
|
@ -37,13 +29,8 @@ def _torrent_jwt(info_dict):
|
||||||
'infohash': _infohash(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'])
|
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):
|
def _infohash(infodict):
|
||||||
digest = hashlib.sha1()
|
digest = hashlib.sha1()
|
||||||
|
|
Reference in a new issue