keb 87d98d038d fix: never show one az account's subscriptions under another (#3)
With two az accounts, signing in to one could make the other account's group list the first one's subscriptions.

**Why:** az can't be told which user to get a token for, so each account is pinned with `--subscription`, using one of its subscriptions. The pin was chosen once at start. But az's profile has one entry per subscription, tagged with the account that signed in to it last. Signing in to another account that also sees the pinned subscription moves it there, and from then on the first account's token requests silently returned the other account's token. That's what happened here: the in-app sign-in as one account re-tagged the other account's default subscription.

**Fix:**
- The pin is looked up in az's profile for every new token (only when the in-memory token cache misses), so it follows az's current mapping. An account with no subscriptions left in az gets "sign in as …".
- A token az issues for **another of the signed-in users** (by its `upn`/`unique_name`/`preferred_username`/`email` claim) is refused with "az gave a token for X, not Y: sign in as Y again", which shows as the usual sign-in prompt. Only a match against another known user is refused, so tokens without those claims (service principals) or with unusual guest names aren't turned away.

Tests cover the subscription moving between users, a refused token, a user gone from az, and the claim matching. I also checked against two real az accounts (one signed in, one expired): the signed-in account lists its subscriptions, and the expired one shows the sign-in error.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Karl-Einar Bergstrøm <karl-einarb@outlook.com>
Reviewed-on: #3
2026-10-11 09:55:43 +02:00
2026-10-10 23:58:25 +02:00
2026-10-10 23:58:25 +02:00
2026-10-10 23:58:25 +02:00
2026-10-10 23:58:25 +02:00
2026-10-10 23:58:25 +02:00
2026-10-10 23:58:25 +02:00
2026-10-10 23:58:25 +02:00
2026-10-10 23:58:25 +02:00
2026-10-10 23:58:25 +02:00
2026-10-10 23:58:25 +02:00

lazysecrets

A terminal UI for finding, reading and sharing secrets. Inspired by the fantastic lazygit.

Main features

  • Read-only: lazysecrets never creates, changes or deletes a secret, so it's safe to point at production. That's by design and may stay that way. (e opens a repo's SOPS or .env file in your editor, or sops edit; any change is yours.)
  • Zero setup: uses the logins you already have (az, the Databricks CLI, sops, git). No config file needed.
  • Search everything: ctrl+s searches every source at once, with fzf-style matching ('exact, ^prefix, suffix$, !not), and jumps straight to the result.
  • Share links: s copies a lazysecrets:// link. A colleague opens it with their own access, from the terminal or with a click in the browser or chat.
  • Careful with values: values stay hidden until you reveal them, and copied values are cleared from the clipboard after 30 seconds.
  • Scriptable: lazysecrets get <link> prints a value for scripts and pipes.
  • Favourites: star the secrets you use most and get back to them in one key.
  • Expiry warnings: secrets, keys and certificates that expire soon are marked.
  • Your way: rebind any key, pick a theme, and add custom commands to run on a secret.
  • Try it first: lazysecrets --demo runs on built-in sample data.
  • Supported platforms: Azure Key Vault, Databricks secret scopes, and SOPS and .env files in your git repos.

Early development: expect rough edges. See CHANGELOG.md for what's new.

Install

On macOS or Linux (arm64 or x86_64):

curl -fsSL https://git.kebcloud.no/keb/lazysecrets/raw/branch/main/install.sh | sh

It installs the latest release into ~/.local/bin after checking it against the release's checksums. sh -s -- v0.2.0 installs a given version, LAZYSECRETS_INSTALL_DIR somewhere else.

lazysecrets looks for a newer release once a day: the footer then shows ↑ v0.2.0, and U shows its changelog and updates in place (or run lazysecrets update).

Or build it yourself: go install git.kebcloud.no/keb/lazysecrets/cmd/lazysecrets@latest.

Get started

az login            # login with azure cli
lazysecrets         # start lazysecrets
lazysecrets --demo  # test with demo data

Pick a source on the left, then a vault, then a secret. The keys you'll use most:

Key Action
j/k, h/l, enter, esc move, switch panes, drill in, back
/ filter the list you're in
space reveal / hide the value
y copy the value (cleared from the clipboard after 30s)
ctrl+s Go to: search everything and jump there
f / F star / your favourites
s copy a link to share
? every key, searchable
q quit

Docs

  • Keys: every key, Go to, the layout, and rebinding keys
  • Azure Key Vault: accounts, permissions, pinned vaults
  • Databricks: profiles and Key Vault-backed scopes
  • SOPS and .env files: which repos and files, decrypting
  • Links: sharing, opening, lazysecrets get in scripts, and opening links from the browser and chat
  • Custom commands: run your own commands on a secret
  • Config: every option, themes, layered configs, the state file
  • Development: building, tests, pull requests and releasing

Privacy

lazysecrets never stores, caches or sends your secret values. It keeps the names and metadata of what you've loaded in a cache file readable only by you, to show it at once next time (cache: false turns it off). It talks only to the services you use it with, and collects no usage data. The one call of its own is a daily check for a new release on this server, which updateCheck: false turns off.

AI disclosure

Built with help from an agentic coding assistant. Every change is requested, reviewed and tested by me before it's merged.

License

Copyright © 2026 Karl-Einar Bergstrøm.

lazysecrets is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. See LICENSE.

v0.2.1
Latest
2026-10-15 10:52:43 +02:00
Languages
Go 99.1%
Shell 0.6%
JavaScript 0.3%