Skip to content

fix(network): pre-fill saved VPN password from the GetSecrets payload - #1472

Open
lkramer wants to merge 1 commit into
pop-os:masterfrom
lkramer:network-vpn-prefill-payload
Open

fix(network): pre-fill saved VPN password from the GetSecrets payload#1472
lkramer wants to merge 1 commit into
pop-os:masterfrom
lkramer:network-vpn-prefill-payload

Conversation

@lkramer

@lkramer lkramer commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

cosmic-applet-network opened the VPN secret prompt with an empty password field even when NetworkManager already had the password saved, because the nmrs agent request discarded the secrets NM includes in its GetSecrets payload.

nmrs 3.4.0 ( freedesktop-rs/nmrs#456 ) surfaces them as SecretRequest.existing_secrets, so the applet pre-fills the dialog from that map, a hinted key, else "password", at the RequestSecret site. Only system-owned secrets appear in the payload (agent-owned and not-saved secrets are never sent to agents), so this covers the common "saved for all users" case with no keyring handling.

  • Built and deployed against a real OpenVPN connection (yoti_vpn, password-flags=0) on Pop!_OS. Before: the field opened blank. After: the saved password is pre-filled on the first prompt.

Note: claude Opus 4.8 was used for coding assistance.

  • [X ] I have disclosed use of any AI generated code in my commit messages.
    • If you are using an LLM, and do not fully understand the changes it is making to the code base, do not create a PR.
    • In our experience, AI generated code often results in overly complex code that lacks enough context for a proper fix or feature inclusion. This results in considerably longer code reviews. Due to this, AI authored or partially authored PRs may be closed without comment.
  • [X ] I understand these changes in full and will be able to respond to review comments.
  • [X ] My change is accurately described in the commit message.
  • [X ] My contribution is tested and working as described.
  • [X ] I have read the Developer Certificate of Origin and certify my contribution under its conditions.

This closes #1444

@jacobgkau

Copy link
Copy Markdown
Member

Thank you for the contribution. #1453 is already in progress to update nmrs to version 3.4, while also migrating some other plumbing to nmrs. This PR also updates nmrs to version 3.4. Would it be reasonable for us to wait to review this until that one's finished?

@lkramer

lkramer commented Jul 10, 2026

Copy link
Copy Markdown
Contributor Author

Thank you for the contribution. #1453 is already in progress to update nmrs to version 3.4, while also migrating some other plumbing to nmrs. This PR also updates nmrs to version 3.4. Would it be reasonable for us to wait to review this until that one's finished?

ah, I hadn't spotted that. I will rebase this one once #1453 is merged.

}

/// Pick a VPN secret from NM's payload: a hinted key first, else `"password"`.
fn pick_secret(src: &HashMap<String, String>, keys: &[String]) -> Option<String> {

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.

Small nit pick if you don't mind: if a hinted key exists but its value is empty, this returns that empty value and filters to None without trying the "password" fallback. Could this skip a valid saved password when NM includes an empty hinted secret plus a populated fallback key?

Maybe filter empties before selecting:

keys.iter()
    .filter_map(|k| src.get(k).filter(|s| !s.is_empty()))
    .next()
    .or_else(|| src.get("password").filter(|s| !s.is_empty()))
    .cloned()

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.

Ah, nice spot! I updated my code.

I don't know what the convention is, the code seems lightweight on unit tests, but to me it made sense to add some for this function to confirm your edge case was solved, so I did. Let me know if you want me to remove them.

`cosmic-applet-network` opened the VPN secret prompt with an empty password
field even when NetworkManager already had the password saved, because the
nmrs agent request discarded the secrets NM includes in its `GetSecrets`
payload.

nmrs 3.4.0 surfaces them as `SecretRequest.existing_secrets`, so the applet
pre-fills the dialog from that map — a hinted key, else `"password"` — at the
`RequestSecret` site. Only system-owned secrets appear in the payload
(agent-owned and not-saved secrets are never sent to agents), so this covers
the common "saved for all users" case with no keyring handling.

- Built and deployed against a real OpenVPN connection (`yoti_vpn`,
  `password-flags=0`) on Pop!_OS. Before: the field opened blank. After:
  the saved password is pre-filled on the first prompt.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cosmic-applet-network: Applet no longer prompts for VPN password when trying to connect (regression in v1.0.14)

3 participants