Skip to content

network: log in to plugin VPNs before activating them - #4281

Merged
bbedward merged 4 commits into
duxlabs-dev:masterfrom
Conava:vpn-auth-dialog
Nov 16, 2026
Merged

bbedward merged 4 commits into
duxlabs-dev:masterfrom
Conava:vpn-auth-dialog

Conversation

@Conava

@Conava Conava commented Nov 15, 2026

Copy link
Copy Markdown
Contributor

Description

Connecting a VPN from DMS failed for every Networkmanager plugin that did not get a dedicated implementation in DMS, like OpenConnect with Cisco AnyConnect or Pulse, gpclient or vpnc. We just assumed the plugin wants a password, but that was never accepted by those plugins so the connection ended with "no valid VPN secrets".

DMS now logs in before the connection starts, the same way the GlobalProtect and Fortinet SAML logins already work:

  • OpenConnect password login is no longer limited to Fortinet, so AnyConnect, Pulse and the other protocols use the DMS prompt or the credentials saved on the profile. If the server asks for more than that, the plugin's own login window opens. Fortinet behaves as before.
  • Other plugins like vpnc, L2TP or strongSwan are asked which secrets they need, and those fields show up in the DMS prompt.
  • Plugins that can only log in through their own window, like gpclient, open that window.
  • No changes in behaviour if the plugins login window isnt installed.

The credentials panel in the control center now hides username and password for profiles that dont support it (vpnc, gpclient, OpenConnect with a certificate).

@cyperion could you try this with your VPN? Its hard to think about every possible config before and a test with real VPNs and configurations would be amazing. It needs Go, make and of course git installed:

git clone --recurse-submodules -b vpn-auth-dialog https://github.com/Conava/dux-shell
cd dux-shell
systemctl --user stop dms
make run

Then connect from the VPN widget as usual. Ctrl+C stops it, and systemctl --user start dms brings your normal shell back.

Type of change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that changes existing behavior)
  • Refactor / internal cleanup
  • Documentation
  • Other

Related issues

Fixes #4204

Screenshots / video

Checklist

  • My code follows the conventions in CONTRIBUTING.md
  • I have tested my changes locally
  • New user-facing strings are wrapped in I18n.tr() with translator context, reusing existing terms where possible
  • Go changes: ran make fmt, added/updated tests, make test passes, and go mod tidy is clean
  • QML changes: ran make lint-qml with no new warnings
  • I have opened a corresponding pull request in dux-docs to document any new behaviors: docs(dms): document VPN logins for other OpenConnect protocols dux-docs#210

For VPN plugins without a dedicated flow, the secret agent guessed a
"password" secret. OpenConnect (AnyConnect, Pulse, ...), gpclient and
vpnc never accept it, so connecting from DMS failed with "no valid VPN
secrets".

Logins now happen in ConnectVPN before activation, like the existing
GlobalProtect and Fortinet SAML flows, and the agent hands NM the
cached result:

- OpenConnect password login (DMS prompt plus openconnect
  --authenticate) is no longer limited to Fortinet. Other protocols use
  openconnect's connect URL and resolve entry, like the plugin's own
  dialog. When the server asks again or for more input, the plugin's
  auth dialog takes over. Fortinet keeps its previous behavior.
- Other plugins run the auth dialog named in their NetworkManager .name
  file. With external UI mode its fields go to DMS's prompt and Save
  persists them; otherwise the plugin's own window opens.
- The OpenConnect and dialog results share one cache. Returned secrets
  without flags are marked not saved first, since NM drops secrets an
  agent returns for keys it treats as system-owned.

A login that fails before activation now marks the profile's row like a
failed activation, and the toast for that failure is shown once.

The credentials panel hides its username and password fields for
profiles that log in through the plugin's dialog and store no
"password" secret, since saving there was never used.
@github-actions github-actions Bot added core Go daemon and CLI under core/ fix ui Quickshell UI under quickshell/ labels Nov 15, 2026
@Conava
Conava marked this pull request as ready for review November 15, 2026 10:20
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Claude review

One data-loss issue in the new secret-flag handling. Otherwise the auth dialog flow looks sound.

  • Marking every returned secret not-saved clears passwords that were saved without a -flags key, core/internal/server/network/backend_networkmanager_vpn.go:477
    Checked: auth dialog protocol and process lifecycle (pipes, kill, WaitDelay, output caps), OpenConnect password and fallback paths, secret cache and pending-save cleanup, ConnectVPN error state vs. QML toast suppression, plugin file parsing, pluginLogin in the control center delegate. Model: claude-opus-5-5.

A plugin's auth dialog asked for secrets NetworkManager already had
stored, and marking what the user typed as not saved made NetworkManager
drop the stored password. A normal user can't read those secrets, so
DMS can't tell whether one is stored.

Secrets without the agent-owned or not-saved flag are now left to
NetworkManager: the dialog path no longer asks for, returns or marks
them, and the secret agent no longer guesses a username and password
for profiles that log in through the plugin's dialog. One-time values
from a plugin's own window are still marked, and only when they differ
from what is stored.
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Claude review

The latest commit fixes the earlier finding about saved secrets being cleared. One new issue: some plugin profiles can no longer get a password from DMS.

  • System-owned secrets with no -flags key and nothing stored are never asked for, and the panel hides their fields too, so L2TP/PPTP profiles without a saved password cannot log in. core/internal/server/network/backend_networkmanager_vpn.go:778
    Checked: the auth dialog process lifecycle (pipes, kill, WaitDelay, output caps); OpenConnect password auth and its fallback to the dialog; markSecretsNotSaved against stored secrets; the secret agent short-circuit for plugin-dialog profiles; the ConnectVPN error-state defer; QML toast suppression through vpnConnectRequest; pluginLogin in the control center delegate. Model: claude-opus-5-5.

var ask []FieldInfo
for _, f := range fields {
switch {
case !secretFlagsAgentAsks(data[f.Name+"-flags"]):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Take a profile with no -flags key and no stored secret, for example an L2TP or PPTP profile made with nmcli connection add ... vpn.data "gateway=...,user=..." and the -gnome plugin installed. DMS can no longer log in to it:

  • This filter drops the password field even though the dialog marks it ShouldAsk, so no prompt appears.
  • GetSecrets (agent_networkmanager.go:243) then returns NoSecrets where it used to infer and prompt for password.
  • PluginLogin is true because password-flags is missing (line 105), so the control center hides the username, password and Save fields too.

The connection fails with "no valid VPN secrets" and DMS offers no way to enter the password. On master, L2TP and PPTP prompted for it.

Fix: only skip a system-owned field if stored already has a value for it. When nothing is stored, ask for it. markSecretsNotSaved will then flag it 2, and nothing saved is lost.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's the case I mentioned in the reply to the other finding, and the suggested fix would bring back the bigger issue.
For a secret without flags DMS can't see whether something is stored: NetworkManager answers with no secrets even when the caller has the modify permission (tested on a vpnc profile with both secrets saved in the keyfile). So "nothing stored" would be true for every profile like this, DMS would ask again and flag the saved password as not saved. I'd rather have nmcli profiles without a saved password fail like this than lose passwords that are saved.
Then the user needs to either save the password or set it to not saved via nmcli or nm-connection-editor (for example nmcli connection modify <name> +vpn.data password-flags=2), after which DMS asks for it on every connect.
Will add this to the docs too

@cyperion

Copy link
Copy Markdown

Hello @Conava,

I have tried to follow your instructions, but DMS is not able to start.

Here is the console log for make run:

make[1]: Verzeichnis „/home/cyperion/dux-shell/core“ wird betreten
Building dms for development...
CGO_ENABLED=0 go build -tags '' -o bin/dms ./cmd/dms
Development build complete: bin/dms
make[1]: Verzeichnis „/home/cyperion/dux-shell/core“ wird verlassen
dms dev
  INFO  go: ipc listening on /run/user/1000/dms-68178.sock
  INFO  go: DMS API Server listening on: /run/user/1000/dms-68178.sock
  INFO  go: API Version: 42
  INFO  go: Protocol: JSON over Unix socket
  INFO  go: Request format: {"id": <any>, "method": "...", "params": {...}}
  INFO  go: Response format: {"id": <any>, "result": {...}} or {"id": <any>, "error": "..."}
  INFO  go:
  INFO  go: Initializing managers...
  INFO  go:
  INFO  go: dms backend ready (ipc=/run/user/1000/dms-68178.sock)
  INFO  go: starting UI (config=/home/cyperion/dux-shell/quickshell)
  INFO  go: Attempting to initialize Wayland gamma control...
  INFO  go: [Tailscale] Connected to IPN bus

██████╗ ███╗   ███╗███████╗
██╔══██╗████╗ ████║██╔════╝
██║  ██║██╔████╔██║███████╗
██║  ██║██║╚██╔╝██║╚════██║
██████╔╝██║ ╚═╝ ██║███████║
╚═════╝ ╚═╝     ╚═╝╚══════╝
loginctl: using XDG_SESSION_ID=4
  INFO  go: Network backend detection: NetworkManager present. Using NM API.
  INFO  go: Wayland gamma control initialized successfully
  INFO  go: Theme mode automation manager initialized
load libdux-qt-base.so.0: libdux-qt-base.so.0: cannot open shared object file: No such file or directory
 ERROR  go: UI exited: exit status 127
 ERROR  go: DMS startup failed (exit code 127). Run 'dms doctor' for more diagnostics.
make: *** [Makefile:35: run] Fehler 127

@Conava

Conava commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for trying @cyperion !
My bad, I forgot a step. Master runs the shell on dux-qt-base now instead of Quickshell, and the 2.1 package you have installed doesn't need it yet, so the library is missing on your system.

It's in the AUR, and it doesn't touch your installed DMS (that one keeps running on Quickshell and you will need it soon anyways):

yay -S dux-qt-base

After that make run should start as before. If you dont want to install anything you can run git submodule update --init && make run QTBASE=1 to build it into the dev binary instead, but that takes longer to compile.

@cyperion

Copy link
Copy Markdown

Thanks, i was able to get it running now!

Here are my observations:
(1) Connecting via the panel widget opens the dialog with username and password fields, but i am not able to write in said fields.
(2) connecting via the settings page opens the dialog and i can enter my credentials without issue. Because the VPN is currently down, I cannot tell if the connection fails due to local issues or just the normal request timeout, but it looks more like the latter (VPN-Connection stuck on Connecting... in settings and fails after about a minute).

Also i was not able to create the new OpenConnect VPN-Connections via settings and had to go back to nm-connections-editor. Currently only WireGuard seems to be supported if I understand the page correctly (+ on VPN automatically opens on a Template with WireGuard in the Name field.

The bar popout kept the keyboard, so the prompt fields took no input. The control center already closes itself for the prompt.
Login fields whose flags leave them to NetworkManager are not asked for, since DMS cannot see whether they are stored. When the connection then fails for missing secrets, name those fields and how to fix it instead of only "Authentication required".
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Claude review

No issues found.
Checked: ConnectVPN auth routing and error/cancel defer, the plugin auth-dialog runner (legacy and external UI mode, stdin/stdout lifetimes, kill paths), system-owned secret skipping and -flags marking, the openconnect password flow for non-Fortinet protocols and its dialog fallback, the secret-agent cache handoff, pluginLogin in profiles and the control center fields, VPN popout close on prompt, and the error toast dedupe in DMSNetworkService. The two earlier inline threads on system-owned secrets have author replies and were not repeated. Model: claude-opus-5-5.

@Conava

Conava commented Nov 15, 2026

Copy link
Copy Markdown
Contributor Author

(1) Found the issue, the VPN popout from the bar kept the keyboard while the login dialog was open. It now closes when the dialog opens.

(2) Getting the dialog and having it accept the credentials is already the important part. Could you try again once the VPN is back up? Then we'll know if the connection itself goes through.

(3) Right, this PR only handles logging in to VPNs that already exist. Settings can create WireGuard profiles and import OpenVPN, vpnc, strongSwan, PPTP/L2TP and openfortivpn config files, but other plugin VPNs like OpenConnect need to be fully set up in nm-connection-editor. DMS then only asks for what the profile doesn't save, like a one-time code. I added that to the docs, and if a login is missing because it isn't saved I made an error explaining that.
This is because supporting many niche VPN configs cannot be maintained and supported reliably so we stick to the minimum that always works here.

@bbedward
bbedward merged commit cb9e2d1 into duxlabs-dev:master Nov 16, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core Go daemon and CLI under core/ fix ui Quickshell UI under quickshell/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GUI Setting openconnect VPN doesn't save credentials correctly

3 participants