openconnect

package
v0.3.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 32 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package openconnect produces the NetworkManager openconnect plugin's secrets without an openconnect binary, the Go counterpart of crates/wayle-network/src/vpn/openconnect.

NetworkManager's openconnect plugin does not ask for a password. It asks for a cookie, a gateway and a gwcert — the output of an authentication, not its input. Conventionally an agent gets those by spawning the plugin's own nm-openconnect-auth-dialog, which drives libopenconnect through the whole sign-in.

lys-shell authenticates itself instead. For GlobalProtect that is a form POST and, when the gateway asks, a second one carrying the 2FA answer; for AnyConnect it is an XML exchange in which the gateway describes the form it wants filled in; Fortinet, Array and the web-login protocols (nc, pulse, f5) are plain HTML form posts. Either way it is plain HTTPS with no tunnel involved, which is exactly what `openconnect --authenticate` does before handing the cookie to something else. The resulting cookie is cached, so a reconnect costs no second factor.

The tunnel itself is still NetworkManager's plugin. This package replaces the sign-in, not the thing that moves packets.

Index

Constants

View Source
const (
	// UsernameKey is where lys-shell keeps the sign-in username. The
	// plugin's auth dialog asks every time; lys-shell stores it in the
	// profile, where it is a setting the user can see and edit rather
	// than hidden state.
	UsernameKey = "lys-shell-username"
	// SSOKey records that this profile wants the browser sign-in
	// ("yes" or "true"). openconnect's own switch for this is a
	// command-line flag, not a profile setting.
	SSOKey = "lys-shell-sso"
	// SignInKey lets a profile ask for the plugin's own auth dialog
	// instead of lys-shell's sign-in: "plugin" opts out; anything else is the
	// default, which is lys-shell. The escape hatch for a gateway lys-shell reads
	// wrong — above all one of the web-login protocols, whose pages are
	// per-deployment markup.
	SignInKey = "lys-shell-signin"
)

The profile's vpn.data keys lys-shell adds of its own; the plugin has no notion of any of them.

View Source
const ServiceType = "org.freedesktop.NetworkManager.openconnect"

ServiceType is the NM service name of the openconnect plugin.

Variables

View Source
var Protocols = []Protocol{
	{"gp", "Palo Alto GlobalProtect"},
	{"anyconnect", "Cisco AnyConnect"},
	{"fortinet", "Fortinet"},
	{"array", "Array Networks"},
	{"nc", "Juniper Network Connect"},
	{"pulse", "Pulse Connect Secure"},
	{"f5", "F5 BIG-IP"},
}

Protocols is every protocol the openconnect plugin speaks, in the order the picker offers them (PROTOCOLS).

Functions

func Authenticate

func Authenticate(ctx context.Context, p Profile, requestNew, unattended bool, prompter secrets.Prompter) (map[string]string, error)

Authenticate signs into the profile's gateway and returns the secrets the openconnect plugin asked for.

requestNew is NM saying the secrets it had were rejected: the cached cookie is dropped and the gateway signed into afresh. The stored password is kept — NM's secrets are the cookie's derivatives, so their rejection says nothing about the password; only the gateway refusing the password itself drops it.

unattended is an activation nobody is watching — a tunnel brought back after a suspend. It gets the cached session if that is still alive, and nothing else: no prompt, and no password posted, since a gateway doing push MFA answers that with a push to a phone nobody is looking at.

Errors are the secrets package's: a refusal (*secrets.AuthenticationFailedError), a sign-in that did not finish (*secrets.SignInIncompleteError), or a gateway this cannot follow (*secrets.ProtocolUnsupportedError).

func DeliverSSOCallback

func DeliverSSOCallback(uri string) bool

DeliverSSOCallback hands a browser callback (a globalprotectcallback: URI) to a waiting GlobalProtect SAML sign-in, reporting whether one was waiting.

func Forget

func Forget(uuid string)

Forget drops everything cached for a profile: the session, the password, and the record of what was last handed over. Called when the profile is deleted: a session cookie and a password outliving their profile is a leak, and a profile recreated under the same name gets a new UUID, so nothing would ever collect them.

func IsSupported

func IsSupported(p Profile) bool

IsSupported reports whether lys-shell can produce this profile's secrets natively.

func RememberPassword

func RememberPassword(uuid, password string)

RememberPassword stores a password the way a sign-in that worked does.

func RememberedPassword

func RememberedPassword(uuid string) (string, bool)

RememberedPassword is the password stored for a profile, and whether there is one.

func SignsInNatively

func SignsInNatively(protocol string) bool

SignsInNatively reports whether lys-shell signs into this protocol itself, rather than leaving it to the plugin's own auth dialog. The form asks this at configuration time, so the answer arrives while the protocol is being picked rather than as a failure on the first connect.

Types

type Profile

type Profile struct {
	UUID     string
	Name     string
	Gateway  string
	Protocol string
	// Username is the stored sign-in username, "" when there is none.
	Username string
	// SSO is whether this profile asked for the browser (SAML) sign-in.
	// Opt-in because advertising the capability is a one-way door per
	// gateway.
	SSO bool
	// PluginSignIn is whether this profile asked to be signed in by the
	// plugin's own auth dialog rather than by lys-shell.
	PluginSignIn bool
}

Profile is the openconnect settings lys-shell needs out of an NM profile.

func ProfileFrom

func ProfileFrom(conn map[string]map[string]dbus.Variant, uuid, name string) (Profile, bool)

ProfileFrom reads an openconnect profile out of NM's connection dictionary (as GetSecrets hands it), or false when this is some other kind of VPN.

type Protocol

type Protocol struct {
	// Value is what the plugin's --protocol takes.
	Value string
	// Label is its display name.
	Label string
}

Protocol is one protocol the openconnect plugin speaks.

Directories

Path Synopsis
Package openconnecttest holds the fakes the NM secret agent's tests need from the openconnect sign-in (the Rust's openconnect::testing::{silent_gateway, reached}).
Package openconnecttest holds the fakes the NM secret agent's tests need from the openconnect sign-in (the Rust's openconnect::testing::{silent_gateway, reached}).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL