š OpenVPN Client Portal

A secure, user-friendly authentication portal for OpenVPN configuration distribution. This application provides Google OAuth2 authentication and domain-restricted access to OpenVPN configuration files.

š Features
- š Secure Google OAuth2 authentication
- š„ Domain-restricted access control
- š¦ Automated OpenVPN config generation
- šØ Clean, responsive web interface
- š Easy deployment and configuration
š¦ Installation
Via pip
pip install gcp-ovpn-portal
Development Setup
git clone https://github.com/ranson21/gcp-ovpn-portal
cd gcp-ovpn-portal
poetry install
š§ Configuration
Google OAuth2 Setup
- Go to the Google Cloud Console
- Create a new project or select an existing one
- Enable the Google OAuth2 API:
- Go to "APIs & Services" > "Library"
- Search for "Google OAuth2"
- Click "Enable"
- Configure the OAuth consent screen:
- Go to "APIs & Services" > "OAuth consent screen"
- Choose "Internal" if using Google Workspace, or "External" if not
- Fill in the application name and other required fields
- Add the necessary scopes (email, profile)
- Create OAuth 2.0 credentials:
- Go to "APIs & Services" > "Credentials"
- Click "Create Credentials" > "OAuth client ID"
- Choose "Web application"
- Add authorized redirect URIs:
- For local development:
http://localhost:8081
- For production:
https://your-domain.com
- Save your Client ID and Client Secret
Environment Variables
The following environment variables are required:
CLIENT_ID
: Google OAuth2 client ID (obtained from steps above)
ALLOWED_DOMAIN
: Authorized email domain (e.g., "company.com")
EXTERNAL_IP
: VPN server's external IP address
OPENVPN_DIR
: Directory containing OpenVPN configuration files (default: /etc/openvpn)
Create a .env file:
cp .env.example .env
Example .env file:
CLIENT_ID=your-google-client-id.apps.googleusercontent.com
ALLOWED_DOMAIN=yourcompany.com
EXTERNAL_IP=203.0.113.1
OPENVPN_DIR=/etc/openvpn
š Usage
Running as an installed package
ovpn-portal
Running in development mode
poetry run ovpn-portal
make run
š Project Structure
openvpn-auth-portal/
āāā ovpn_portal/
ā āāā app/
ā ā āāā main/
| ā ā āāā __init__.py
| ā ā āāā routes.py
ā ā āāā __init__.py
ā ā āāā config.py
ā ā āāā middleware.py
ā ā āāā vpn.py
ā āāā run.py
āāā static/
ā āāā css/
ā āāā images/
ā āāā js/
ā āāā favicon.ico
āāā templates/
ā āāā index.html
āāā tests/
āāā pyproject.toml
āāā .env.example
āāā .gitignore
āāā README.md
š ļø Development
The project includes a Makefile to help with common development tasks:
First Time Setup
make dev-setup
Common Commands
make install
make run
make test
make coverage
make format
make lint
make clean
Test Coverage
To run tests with coverage reporting:
make coverage
This will:
- Run all tests with coverage tracking
- Generate a terminal report showing missing lines
- Create an HTML coverage report in
coverage_html/
View the HTML coverage report:
make coverage-open
Package Management
make build
make develop
Publishing
make publish-test
make publish
You can also use Poetry directly for development tasks:
poetry install
poetry run pytest
poetry run black .
poetry run flake8
š Security Considerations
- All authentication is performed through Google OAuth2
- Configuration files are generated temporarily and immediately deleted after download
- Domain restriction ensures only authorized users can access the portal
- HTTPS is required in production
š License
This project is licensed under the MIT License - see the LICENSE file for details.
š¤ Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
š¤ Author
Abigail Ranson