Microsoft SSO + Azure Key Vault credential management for Sanoptis Claude Code plugins.
Project description
sanoptis-auth
Microsoft SSO + Azure Key Vault credential management for Sanoptis Claude Code plugins.
A single library that any Sanoptis plugin can use to fetch its API secrets, gated by the user's normal Microsoft sign-in. No more per-plugin dotfiles, chmod gymnastics, or hand-rolled credential bootstrap docs.
Install
pip install sanoptis-auth
What it does
- Fetches secrets from
kv-sanoptis-pluginsAzure Key Vault. - Authenticates the user via Microsoft device-code flow on first use; caches the refresh token (90 days) for subsequent calls.
- Surfaces the login prompt as a clickable link in Claude chat (via the bundled
start_sanoptis_loginMCP tool) — no terminal required. - Enforces RBAC at the Entra security-group level: a user with
sg-sanoptis-plugin-yokoy-userscan fetch yokoy secrets but not DATEV secrets, even from the same machine.
Use it in a plugin
Add to your plugin's requirements.txt:
sanoptis-auth>=0.1.2
Replace any per-plugin credential loading with:
from sanoptis_auth import get_secret
api_key = get_secret("yokoy--api-key")
api_secret = get_secret("yokoy--api-secret")
Register the MCP server alongside your own in .mcp.json so users can run start_sanoptis_login from chat:
{
"mcpServers": {
"sanoptis-auth": {
"command": "python",
"args": ["-m", "sanoptis_auth.mcp_server"],
"env": {
"PYTHONPATH": "${CLAUDE_PLUGIN_DATA}/site-packages",
"CLAUDE_PLUGIN_DATA": "${CLAUDE_PLUGIN_DATA}"
}
}
}
}
First-time login (end user)
- Install the plugin in Claude Code or Cowork.
- Use any tool that needs a secret. Claude will say something like "Sanoptis login required — run the start_sanoptis_login tool."
- Run that tool. Claude shows you a clickable Microsoft device-code URL and a short code.
- Click the link, sign in with your Sanoptis Microsoft account, paste the code.
- Done — the next 90 days of plugin usage are automatic.
Local dev override
For working offline or before your Entra group membership is set up:
export SANOPTIS_AUTH_LOCAL_OVERRIDE_FILE=~/.sanoptis-auth-overrides.env
cat > ~/.sanoptis-auth-overrides.env <<'EOF'
yokoy--api-key=dev-key
yokoy--api-secret=dev-secret
EOF
chmod 600 ~/.sanoptis-auth-overrides.env
get_secret() checks this file first when the env var is set.
Adding a new secret to the vault
az login --tenant ea0bd7d3-b29f-47f4-aedc-da7b52a28ba0
az keyvault secret set --vault-name kv-sanoptis-plugins --name "myplugin--api-key" --value "..."
Or use the rotate-secrets.yml GitHub Actions workflow (workflow_dispatch) for an audited rotation.
Adding a new plugin
- Add a
pluginsentry ininfra/variables.tf(e.g.,"myplugin"). - PR →
terraform-planposts the diff (new security group + role assignments). - Merge →
terraform-applyprovisionssg-sanoptis-plugin-myplugin-usersand binds it to scoped KV secret access. - Add teammates to the new group in Entra.
- In your plugin code:
get_secret("myplugin--api-key").
Repo layout
| Path | Purpose |
|---|---|
sanoptis_auth/ |
Python package: MSAL + KV client + MCP server |
sanoptis_auth/mcp_server/ |
stdio MCP server exposing start_sanoptis_login and whoami |
tests/ |
pytest suite (unit + mocked Azure) |
infra/ |
Terraform: KV, Entra app, security groups, role assignments, GHA OIDC |
.github/workflows/ |
CI, release, terraform plan/apply, secret rotation |
Architecture decisions
- Public client (no client secret). The Entra app uses delegated access — secrets are read as the signed-in user, not as the app. Nothing to leak or rotate at the app level.
- Per-plugin token cache. Each plugin's
${CLAUDE_PLUGIN_DATA}dir gets its own MSAL cache. The user signs in once per plugin; refresh tokens last 90 days. Trade-off: prevents one plugin from reading another's tokens. - Hand-rolled MSAL over
azure-identity.DefaultAzureCredential.DefaultAzureCredentialtries 7 different credential chains and surfaces opaque error messages. We usemsal.PublicClientApplicationdirectly with a single device-code path — failures are explicit. - Group-scoped RBAC at the secret level. A user with
sg-sanoptis-plugin-yokoy-userscannot read DATEV secrets even if they install the DATEV plugin. RBAC is enforced by Azure Key Vault, not by application code. - Terraform over Bicep. Reviewable, multi-cloud-portable, and the standard Sanoptis-BI infra tool. Runs via OIDC federated identity in CI — no service principal secret stored in GitHub Actions.
Provisioning new infrastructure
See infra/README.md for the one-time Azure bootstrap procedure (Andrej / Matthias action).
Source of truth
This repo is the only place credentials for Sanoptis Claude Code plugins should be managed. If you find a plugin reading secrets from a dotfile or environment variable, file an issue — it should be migrated to sanoptis_auth.get_secret.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file sanoptis_auth-0.1.2.tar.gz.
File metadata
- Download URL: sanoptis_auth-0.1.2.tar.gz
- Upload date:
- Size: 52.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f16b624af7db30c5c8df8aee75846193425386a4d7bae9e44660e0e5dbd8f185
|
|
| MD5 |
513b9caf09d1b489848963aa4e9d9670
|
|
| BLAKE2b-256 |
9c0d884c4c84f184b6881c6d0f0c1b8b82baeb592961979b93928c5f32fb60d7
|
Provenance
The following attestation bundles were made for sanoptis_auth-0.1.2.tar.gz:
Publisher:
publish.yml on Sanoptis-BI/sanoptis-auth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sanoptis_auth-0.1.2.tar.gz -
Subject digest:
f16b624af7db30c5c8df8aee75846193425386a4d7bae9e44660e0e5dbd8f185 - Sigstore transparency entry: 1293580495
- Sigstore integration time:
-
Permalink:
Sanoptis-BI/sanoptis-auth@73947009c5872d6d6ef19a9ccfbfb5924a221013 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Sanoptis-BI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@73947009c5872d6d6ef19a9ccfbfb5924a221013 -
Trigger Event:
push
-
Statement type:
File details
Details for the file sanoptis_auth-0.1.2-py3-none-any.whl.
File metadata
- Download URL: sanoptis_auth-0.1.2-py3-none-any.whl
- Upload date:
- Size: 18.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a4fc1453a40bc5aac0803debef4a2d455bf7b5ddfad0271411b1a7759d0af6d
|
|
| MD5 |
1f0fd73f66821554d391734b3bc01566
|
|
| BLAKE2b-256 |
7e7638fdff0e89ad1251a529d043defa4de05f93708557083634c3f0e3986798
|
Provenance
The following attestation bundles were made for sanoptis_auth-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on Sanoptis-BI/sanoptis-auth
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
sanoptis_auth-0.1.2-py3-none-any.whl -
Subject digest:
5a4fc1453a40bc5aac0803debef4a2d455bf7b5ddfad0271411b1a7759d0af6d - Sigstore transparency entry: 1293580506
- Sigstore integration time:
-
Permalink:
Sanoptis-BI/sanoptis-auth@73947009c5872d6d6ef19a9ccfbfb5924a221013 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/Sanoptis-BI
-
Access:
private
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@73947009c5872d6d6ef19a9ccfbfb5924a221013 -
Trigger Event:
push
-
Statement type: