Skip to main content

OpenVPN Control Panel for Restricted Network.

Project description

OpenVPN Control Panel for Restricted Network

Tests CodeQL Advanced Package

Installation

In order to run along with OpenVPN server, the ROOT privilege is required.

sudo pipx install ovpncp

OpenVPN Server Setup

Make sure the client-to-client directive is disabled:

;client-to-client

Enable CCD & make it exclusive:

client-config-dir /etc/openvpn/ccd
ccd_exclusive

Enable the scripts of client connection:

client-connect /opt/ovpncp/scripts/client-connect.sh
client-disconnect /opt/ovpncp/scripts/client-disconnect.sh

Start the application:

sudo -i ovpncp

Restart the server:

sudo systemctl restart openvpn

Basic Usage

Init server by calling API with cURL:

curl -X POST http://127.0.0.1:8000/server

Check the health of OpenVPN server:

curl -X GET http://127.0.0.1:8000/server/health

Client Setup

Create a client:

curl -X POST http://127.0.0.1:8000/clients \ 
    -d '{"name": "client_1"}'

Create a gateway client with the private network behind it:

curl -X POST http://127.0.0.1:8000/clients \ 
--data-binary @- << EOF 
{
    "name": "gateway_1", 
    "cidr": "192.168.1.0/24"
}
EOF

Package the client certificate:

curl -X PUT http://127.0.0.1:8000/clients/client_1/package-cert

Download the archive:

curl -X GET http://127.0.0.1:8000/clients/client_1/download-cert

Assign IP to the client:

curl -X PUT http://127.0.0.1:8000/clients/client_1/assign-ip \ 
    -d '{"ip": "10.8.0.2"}'

Unassign IP from the client:

curl -X DELETE http://127.0.0.1:8000/clients/client_1/unassign-ip

Restricted Network Setup

IMPORTANT: make sure drop all forwarding on tun0 by default:

sudo iptables -A FORWARD -i tun0 -j DROP

Create a restricted network between two clients:

curl -X POST http://127.0.0.1:8000/networks \ 
--data-binary @- << EOF 
{
    "source_name": "client_1", 
    "destination_name": "edge_device_1",
}
EOF

Create a restricted network between a client and a gateway:

curl -X POST http://127.0.0.1:8000/networks \ 
--data-binary @- << EOF 
{
    "source_name": "client_1", 
    "destination_name": "edge_gateway_1", 
    "private_network_addresses": "192.168.1.1,192.168.1.2,192.168.1.3"
}
EOF

Add an IP route for allowing traffic on the OpenVPN server:

curl -X POST http://127.0.0.1:8000/server/routes \
--data-binary @- << EOF 
{
    "network": 192.168.1.0/24"
}
EOF

Drop the network:

curl -X DELETE http://127.0.0.1:8000/networks/1

[Optional] Enable Security with Azure Entra ID

Register this app on Azure Entra ID first, then sets three ENVs to enable the security middleware:

  1. TENANT_ID - the tenant ID of Azure Entra ID directory.

  2. APP_CLIENT_ID - the application (client) ID of this app that registered.

  3. APP_ROLE - the app role assigned by this app.

Notice: for client app, two things must be configured on the client app registration:

  1. enable the optional claim aud of token type Access on the Token configuration;

  2. add the permission of this app on the API permissions.

[Optional] Enable Cert Management with Azure Blob Storage

  1. Create a storage account on Azure Portal.

  2. Create a container named ovpncp on the storage account.

  3. Obtain the access key and set it to the AZURE_STORAGE_CONNECTION_STRING

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ovpncp-0.1.5.tar.gz (29.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ovpncp-0.1.5-py3-none-any.whl (24.8 kB view details)

Uploaded Python 3

File details

Details for the file ovpncp-0.1.5.tar.gz.

File metadata

  • Download URL: ovpncp-0.1.5.tar.gz
  • Upload date:
  • Size: 29.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ovpncp-0.1.5.tar.gz
Algorithm Hash digest
SHA256 9531e45c88d13dc9407e6fcf1dc2eaed979a726922e29c98f6fde621b34c5771
MD5 7fd0524e96493acdec4557ad3172b0b9
BLAKE2b-256 4ebf6ed9db8a79f923e685c2c1eaf8c5d9ddd76eae0628664ae7c7ded4243b3c

See more details on using hashes here.

Provenance

The following attestation bundles were made for ovpncp-0.1.5.tar.gz:

Publisher: package.yml on scia-iot/ovpncp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ovpncp-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: ovpncp-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 24.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for ovpncp-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 926575bceb8b85df32f0040afb11817c3a138e16a76c39f3ed18c18514dd66f5
MD5 d245c585725af567489dec7e89dc830f
BLAKE2b-256 b74e9ff6f55409ef6b3b30154eb1870b36bf377f544f44c4fa3e9ab0cd9a8fa2

See more details on using hashes here.

Provenance

The following attestation bundles were made for ovpncp-0.1.5-py3-none-any.whl:

Publisher: package.yml on scia-iot/ovpncp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page