NETunnel-JWThenticator
An authentication plugin of NETunnel that uses JWThenticator to provide key-based authentication between peers.
The plugin designed to be used in a server-server NETunnel models (although it can
be used in a client-server model as well) where each machine has a web server
that exposes a JWThenticator and a NETunnel service.
The web server protects the NETunnel routes by verifying that the JWT token
in every request's Authorization header is signed by the local JWThenticator
service.
When a new peer is registered on a NETunnel server, you'll need to provide a key, which you're obligated to make sure it is registered on the remote JWThenticator server. The plugin will make a request to the remote JWThenticator server for a refresh token, using the provided key. The refresh token will be stored as the auth data of this peer, and for every new request, the plugin will make sure there is a valid JWT token that it received from the remote JWTheneticator server using the refresh token.
Getting Started
Installing
pip install netunnel-jwthenticator
Usage
The plugin was designed to be used in a server-server model of NETunnel, so the examples will focus on that. Each machine should have a running JWThenticator server and a NETunnel server with this plugin activated:
python -m netunnel.server --auth-plugin netunnel_jwthenticator.JWThenticatorAuthServer
Make sure both the JWThenticator and NETunnel are listening only on localhost, and
have your web server proxy NETunnel on /netunnel and JWThenticator on /jwthenticator.
expose only the "public" routes for JWThenticator:
/authenticate/refresh/validate/jwks
As for NETunnel, have your web server expose the following routes only after validating the JWT token of each request:
/version/channels/channels/*
For example, for an NGINX web server, you could use the auth_request directive to
achieve that:
http {
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 443 ssl;
location /netunnel/ {
auth_request _jwthenticator_validate;
if ($uri !~ "^/netunnel/version$|^/netunnel/channels$|^/netunnel/channels/.+$") {
return 403;
}
rewrite /netunnel/(.*) /$1 break;
proxy_pass http://127.0.0.1:4040;
# support websockets
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
location /jwthenticator/ {
if ($uri !~ "^/jwthenticator/authenticate$|^/jwthenticator/refresh$|^/jwthenticator/validate$|^/jwthenticator/jwks$") {
return 403;
}
rewrite /jwthenticator/(.*) /$1 break;
proxy_pass http://127.0.0.1:5050;
}
location _jwthenticator_validate {
internal;
proxy_pass_request_body off;
proxy_set_header Content-Length "";
proxy_pass http://127.0.0.1:5050/validate_request;
}
}
}
Custom URIs
If you wish to use different URIs than /netunnel and /jwthenticator, you can do so for NETunnel, you'll
anyway need to provide the full URL when registering the peer.
As for JWThenticator, the plugin assumes the remote JWThenticator is at /jwthenticator,
so you'll have to initialize it differently by either providing the following flag to
netunnel server: --auth-data '{"remote_uri": "<new-uri>"}' or by settings the following
environment before starting the server: export JWTHENTICATOR_URI=<new-uri>
Changelog
1.0.1
First release
Metadata
Release files for netunnel-jwthenticator 1.0.3
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 | Actions |
|---|---|---|---|---|
| netunnel_jwthenticator-1.0.3.tar.gz | 8.5 kB | Without provenance | Details for netunnel_jwthenticator-1.0.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| netunnel_jwthenticator-1.0.3-py3-none-any.whl | Python 3 | none | any | Details for netunnel_jwthenticator-1.0.3-py3-none-any.whl |
Total release size: 17.3 kB
Release files / netunnel_jwthenticator-1.0.3.tar.gz
| Download URL | netunnel_jwthenticator-1.0.3.tar.gz |
|---|---|
| Size | 8.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
76e3c0b10f7961ff772dec330573cd6be6905e648aca274f1468301484844008
|
|
BLAKE2b-256 checksum How to use checksums |
c54e927cb69f97f10d21a6f4427d36dd5f3037f587771ee032cc64b5be2cecd2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Release files / netunnel_jwthenticator-1.0.3-py3-none-any.whl
| Download URL | netunnel_jwthenticator-1.0.3-py3-none-any.whl |
|---|---|
| Size | 8.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ba19c541828806515c685cf29f0c955616eb120c85c3e270e59382ed4bf59a6d
|
|
BLAKE2b-256 checksum How to use checksums |
2b185a4557954c9d2695f442a3ce1a58a7f0cfb0c39cb19978ea177f087ed3b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.12.8
|
Security for netunnel-jwthenticator 1.0.3
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.