Skip to main content

Wrapper script for OpenConnect supporting Azure AD (SAMLv2) authentication to Cisco SSL-VPNs

Project description

openconnect-sso-mtls

Tests

A wrapper for OpenConnect that handles SAMLv2/SSO authentication to Cisco SSL-VPNs. Automates the browser-based login flow and passes the resulting session token to openconnect. Includes automatic client certificate (mTLS) selection from the system keystore.

Fork of vlaci/openconnect-sso.

Requirements

  • Linux or macOS
  • openconnect installed and on $PATH
  • Python 3.12+

Installation

pipx install git+https://github.com/jmesterh/openconnect-sso-mtls

Usage

If Cisco AnyConnect or Secure Client is installed, existing VPN profiles are detected automatically. In most cases, just run:

openconnect-sso

The server address and credentials are saved between sessions, so subsequent runs require no arguments.

To connect to a specific server for the first time:

openconnect-sso --server vpn.server.com/group --user user@domain.com

Passing arguments to openconnect

Additional openconnect arguments can be appended after --:

openconnect-sso -- --base-mtu=1370

Client certificates (mTLS)

When the VPN server requests a client certificate during the SSO flow, the tool selects the first matching certificate from the system keystore automatically. No configuration is required.

Authentication groups

Use --list-authgroups to discover what groups your VPN server exposes:

$ openconnect-sso --list-authgroups
CardinalKey
CardinalKey-Full

Then connect directly to a group:

openconnect-sso --authgroup "CardinalKey-Full"

Authenticate only (no tunnel)

Output session credentials without starting the tunnel — useful for scripting:

openconnect-sso --authenticate shell
openconnect-sso --authenticate json

Configuration

Configuration is stored at $XDG_CONFIG_HOME/openconnect-sso/config.toml (typically ~/.config/openconnect-sso/config.toml).

TOTP / push-based MFA

For environments where the SSO page requires a TOTP code, adjust config.toml to fill and submit it:

[[auto_fill_rules."https://*"]]
selector = "input[data-report-event=Signin_Submit]"
action = "click"

[[auto_fill_rules."https://*"]]
selector = "input[type=tel]"
fill = "totp"

CLI reference

openconnect-sso [OPTIONS] [-- OPENCONNECT_ARGS]

Server connection:
  -s, --server SERVER              VPN server address (host, host/group, or full URL)
  -p, --profile PROFILE_PATH       Load profiles from file or directory
  -P, --profile-selector           Always display profile selector
      --proxy PROXY                Use a proxy server

Authentication:
      --authgroup AUTHGROUP        Set authentication group, skipping the interactive selector
      --list-authgroups            Query available authentication groups and exit
  -g, --usergroup USERGROUP        Override usergroup from --server
      --authenticate [FORMAT]      Authenticate only; output credentials as shell or json

Credentials:
  -u, --user USER                  Authenticate as the given user

Options:
      --browser-display-mode       shown (default) or hidden
      --full-tunnel                Strip split-tunnel routes, force full tunnel
      --on-disconnect CMD          Command to run on disconnect
      --ac-version VERSION         AnyConnect version string (default: 4.7.00136)
  -l, --log-level LEVEL            ERROR, WARNING, INFO, or DEBUG
  -V, --version                    Print version and exit

Development

uv run pytest

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

openconnect_sso_mtls-1.0.0.tar.gz (101.6 kB view details)

Uploaded Source

Built Distribution

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

openconnect_sso_mtls-1.0.0-py3-none-any.whl (38.9 kB view details)

Uploaded Python 3

File details

Details for the file openconnect_sso_mtls-1.0.0.tar.gz.

File metadata

  • Download URL: openconnect_sso_mtls-1.0.0.tar.gz
  • Upload date:
  • Size: 101.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for openconnect_sso_mtls-1.0.0.tar.gz
Algorithm Hash digest
SHA256 92a7c01f15ba572674c7dcb2410190af40f71571f300dedaf30ebd0b71e20b88
MD5 febf2146d5c430c1a951da8f45ae6b58
BLAKE2b-256 edbab4de12849a18377f197e396e75104dfe6a04ef032278cf415204864ae584

See more details on using hashes here.

Provenance

The following attestation bundles were made for openconnect_sso_mtls-1.0.0.tar.gz:

Publisher: release.yml on jmesterh/openconnect-sso-mtls

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

File details

Details for the file openconnect_sso_mtls-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for openconnect_sso_mtls-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 16b28be3c515befd3af2f62bba54a301beee9a9d1dd8d1b44570446a40869190
MD5 865d0483366aececb3f22ca19e8f2f19
BLAKE2b-256 ccc5a9f387e296e4e46a1693ed992ddf2f9eca0922553458884391933b4515ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for openconnect_sso_mtls-1.0.0-py3-none-any.whl:

Publisher: release.yml on jmesterh/openconnect-sso-mtls

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