Korv is an API framework that uses TCP sockets over SSH to exchange JSON data with a REST-like protocol. It's built on top of the asyncssh module, so it uses asyncio to manage the sockets and its callbacks. This allows you to build rich APIs with the session security of SSH and without the TCP overhead of HTTP.
Communications over this framework requires SSH keys like logging into a normal SSH server:
- The server itself has a private key and a set of public keys for the authorized clients.
- The client has a private key and a set of public keys for the servers it can connect to.
Verbs
There are 4 main verbs that indicate the intent of your request:
GETfor retrieving information.STOREfor creating new objects.UPDATEfor changing existing objects.DELETEfor removing objects.
Keys
As discussed previously, you establish an SSH session with the server, so it's possible to reuse existing keys or generate them through any standard mechanism like the one below:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
Server
Getting a server up and running is very simple:
from korv import KorvServer
def hello(request):
"""Callback for the /hello endpoint"""
return 200, {'msg': 'Hello World!'}
def echo(request):
"""Callback for the /echo endpoint"""
return 200, {'msg': f'{request}'}
# Create a server
k = KorvServer(host_keys=['PATH_TO_YOUR_SERVER_PRIVATE_KEY'], authorized_client_keys='PATH_TO_YOUR_AUTHORIZED_PUBLIC_KEYS')
# Register the callbacks
k.add_callback('GET', '/hello', hello)
k.add_callback('GET', '/echo', echo)
# Start listening for requests
k.start()
This will start a new SSH server with the specified private key that listens on port 8022 by default and will accept the clients listed in the authorized keys.
Client
Following is an example on how to communicate with this server.
>>> from korv import KorvClient
>>>
>>> # Create the client
>>> k = KorvClient(client_keys=['PATH_TO_YOUR_CLIENTS_PRIVATE_KEY'])
>>>
>>> # Issue a GET request and print the output
>>> k.get('/hello', callback=lambda response: print(response['body']))
>>> {'msg': 'Hello World!'}
Return Codes
We're using standard HTTP response codes:
200= Success.400= Malformed request or missing parameters.404= NotFound500= Internal error.
Server exceptions map to a 500 return code ans will include a traceback in the response.
Metadata
Release files for korv 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| korv-0.2.1.tar.gz | 5.2 kB | Without provenance | Details |
Release files / korv-0.2.1.tar.gz
| Download URL | korv-0.2.1.tar.gz |
|---|---|
| Size | 5.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9f174e27a0eb032d661aea86f76ff1a49434e57969cc3eb9a0fad5c88cf52ae7
|
|
BLAKE2b-256 checksum How to use checksums |
35cc329346d1c336696d5e8d8195b01d2cb9d785106ebda5b2d9283c762be9d6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.12.1 pkginfo/1.4.2 requests/2.18.4 setuptools/39.0.1 requests-toolbelt/0.8.0 tqdm/4.23.1 CPython/3.6.5
|
Security for korv 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.