inter service command execution protocol
While working on yamcsr I had to find a way to call scripts
(which are part of yamcsr
codebase) from outside of its containerized environment (without code/volumes duplication).
Then I came up with this idea, a middleware that can handle multiple connections, has decent security (token authentication + connection encryption), can execute predefined command / scripts (+ get it's results) and is easy to use.
At first I wanted to build it with Python socketserver, but when it came to expanding codebase built on it, I find it quite difficult and non-intuitive, that's why I decided to build my own solution.
That is how this project came to life. It is quite simple but was a nice exercise is using Python sockets and multithreading.
- multithreaded socket server.
- limiting max threads/connections that can be handled at the same time.
- client implementation.
- support loging (access, error, commands).
- SSL/TLS communication encryption.
- token based packets authentication.
- built-in CLI to manage authentication tokens.
- fully type hinted.
Size | Type | Content | Checksum / Hash |
---|---|---|---|
4 bytes | 2 bytes | x bytes | 32 bytes |
package can be installed via pip
just add following line to your
requirements.txt
(remember to specify proper version).
iscep @ git+https://github.com/zNitche/iscep.git@<version>
Client
and Server
example scripts can be found in /examples
directory.
Following command will add token to $PWD/tokens.json
for user <user_name>
.
python3 -m iscep.tokens_management --tokens-path tokens.json --add user_name
iscep
supports connection encryption (see /examples/client.py
and /examples/server.py
), to use it
certificate and key have to be generated with following command:
openssl req -x509 -newkey rsa:2048 -nodes -out cert.pem -keyout key.pem -days 365
paths to cert.pem
and key.pem
must be specified in Client
and Server
instance.
In order to run tests or build package, project development dependencies have to be installed.
pip3 install -r requirements-dev.txt
To build package, that can be installed manually can be done with following command.
python3 -m build
project's test suit can be run via
pytest -v tests/