mirror of
https://code.eliotberriot.com/funkwhale/funkwhale.git
synced 2025-10-03 21:59:16 +02:00
Basic logic for signing/verifying requests
This commit is contained in:
parent
ae65190364
commit
aa7365b71f
7 changed files with 98 additions and 2 deletions
30
api/funkwhale_api/federation/factories.py
Normal file
30
api/funkwhale_api/federation/factories.py
Normal file
|
@ -0,0 +1,30 @@
|
|||
import factory
|
||||
import requests
|
||||
import requests_http_signature
|
||||
|
||||
from funkwhale_api.factories import registry
|
||||
|
||||
from . import signing
|
||||
|
||||
|
||||
registry.register(signing.get_key_pair, name='federation.KeyPair')
|
||||
|
||||
|
||||
@registry.register(name='federation.SignatureAuth')
|
||||
class SignatureAuthFactory(factory.Factory):
|
||||
algorithm = 'rsa-sha256'
|
||||
key = factory.LazyFunction(lambda: signing.get_key_pair()[0])
|
||||
key_id = factory.Faker('url')
|
||||
|
||||
class Meta:
|
||||
model = requests_http_signature.HTTPSignatureAuth
|
||||
|
||||
|
||||
@registry.register(name='federation.SignedRequest')
|
||||
class SignedRequestFactory(factory.Factory):
|
||||
url = factory.Faker('url')
|
||||
method = 'get'
|
||||
auth = factory.SubFactory(SignatureAuthFactory)
|
||||
|
||||
class Meta:
|
||||
model = requests.Request
|
Loading…
Add table
Add a link
Reference in a new issue