Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ Key principles:
| `src/vip/bundle/` | `vip bundle` internals: `summary.py` (allowlisted config summary and the secret list, with a selftest that fails on an unclassified config field), `archive.py` (allowlisted report files, encoded-form secret scan, atomic zip write), and `stamp.py` (the `_output/.vip-render.json` stamp that `vip report` writes, so that a bundle holds only rendered files made from its own `results.json`) |
| `src/vip/config.py` | TOML config loader and dataclasses (includes `[proxy]` → `ProxyConfig`) |
| `src/vip/proxy.py` | Single source of truth for outbound-proxy resolution. `ProxyConfig` + `build_proxy_map` (mirrors httpx's `get_environment_proxies`, incl. NO_PROXY formatting), `build_mounts` (per-scheme `HTTPTransport` mounts that keep `verify`), `proxy_for_url` (httpx-identical most-specific-pattern selection, used by non-httpx probes), `playwright_proxy` (renders a Playwright `launch(proxy=)` dict). Every HTTP egress path routes through this so VIP never diverges from httpx's own env-proxy behavior — see "Outbound proxy support" below |
| `src/vip/auth/` | Interactive and headless browser authentication for OIDC providers, split into `browser.py` (Chromium launch, `InteractiveAuthSession`), `cache.py`, `flows.py` (`start_interactive_auth`, `start_headless_auth`), `sso.py`, `workbench.py`, `scheme.py` (`resolve_url_scheme`) and `apikey.py` (Connect API-key minting); `__init__.py` re-exports the names callers import from `vip.auth`, but a selftest must patch a helper on the submodule that calls it; `authenticated_page` opens a headless page from a cached auth session for `vip cleanup --workbench-url`; `auth_cache_path()` is the single source of truth for the `.vip-auth-cache.json` location (both `plugin/auth.py` and `cli/cleanup.py` must use it), and `_load_cached_auth` probes Workbench before trusting a cached session; `refresh_auth_cache_from_storage_state` writes a live context's cookies back over a cache whose session has been invalidated (atomic, 0600, existing caches only); both cache writers drop Entra's long-lived `ESTSAUTHPERSISTENT` cookie (`_CACHE_DROPPED_COOKIES`) because Entra sets it even when "Stay signed in?" is answered No |
| `src/vip/auth/` | Interactive and headless browser authentication for OIDC providers, split into `browser.py` (Chromium launch, `InteractiveAuthSession`), `cache.py`, `flows.py` (`start_interactive_auth`, `start_headless_auth`), `sso.py`, `workbench.py`, `scheme.py` (`resolve_url_scheme`) and `apikey.py` (Connect API-key minting); `__init__.py` re-exports the names callers import from `vip.auth`, but a selftest must patch a helper on the submodule that calls it; `authenticated_page` opens a headless page from a cached auth session for `vip cleanup --workbench-url`; `auth_cache_path()` is the single source of truth for the `.vip-auth-cache.json` location, under the user cache dir (`%LOCALAPPDATA%` on Windows, else `$XDG_CACHE_HOME` or `~/.cache`) in `vip/auth/<hash of cwd>/`, never in cwd; it only computes the path (`None` when there is no home directory or cwd). `prepare_auth_cache()` runs on every `vip verify` (in `plugin/auth.py`, pytest controller only) and every `vip cleanup` (`cli/cleanup.py`), with or without a browser login, and both login paths must take the cache path from it: it makes `vip/` and `vip/auth/` owner-only, moves a legacy cwd cache there as a state+meta pair (deleting it if the move fails), and prunes other directories' caches past `AUTH_CACHE_PRUNE_AFTER_SECONDS` (a day, so a run that reused a cache just inside the 4-hour `AUTH_CACHE_TTL_SECONDS` keeps its storage state). `_load_cached_auth` treats a state file with no `.meta.json` as a miss and probes Workbench before trusting a cached session; `refresh_auth_cache_from_storage_state` writes a live context's cookies back over a cache whose session has been invalidated (atomic, 0600, existing caches only); both cache writers drop Entra's long-lived `ESTSAUTHPERSISTENT` cookie (`_CACHE_DROPPED_COOKIES`) because Entra sets it even when "Stay signed in?" is answered No |
| `src/vip/idp.py` | IdP login form strategies for headless auth (Keycloak, Okta, Snowflake, Entra ID) |
| `src/vip/attest.py` | The two skip helpers (`not_applicable`, `unproven`) that record whether a skipped check was out of scope or simply never verified |
| `src/vip/errors.py` | The `VipError` exception hierarchy for user-facing CLI failures (`ConfigError`, `AuthError`, `ProductUnreachableError`, `InstallError`, `ReportError`, `BundleError`, `AuthConfigError`, `AuthTimeoutError`), each carrying an `exit_code`; raise one instead of calling `sys.exit` from command code — see "Error handling" below |
Expand Down
29 changes: 29 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,35 @@ Fast confidence check — skip the detailed/long-running checks:
vip verify --config vip.toml --basic
```

### Credentials on disk

`--interactive-auth` and `--headless-auth` cache a live session for 4 hours:
the identity provider (IdP), Connect, and Workbench cookies, plus a Connect
API key that VIP creates. VIP keeps one cache for each directory you run it
from, in a folder named after a hash of that directory:

| Platform | Location |
|---|---|
| Linux, macOS | `$XDG_CACHE_HOME/vip/auth/<hash>/`, or `~/.cache/vip/auth/<hash>/` when `XDG_CACHE_HOME` is unset |
| Windows | `%LOCALAPPDATA%\vip\auth\<hash>\` |

Only your user can read these folders. Each `vip verify` or `vip cleanup`
deletes caches that have not been written for a day. VIP never reuses a cache
older than 4 hours, and the next login deletes the API keys of expired caches
from Connect. To sign out now,
delete the `vip/auth` folder. With no home directory and no `XDG_CACHE_HOME`,
VIP skips the cache.

Earlier releases wrote `.vip-auth-cache.json` and `.vip-auth-cache.meta.json`
into the working directory. The first `vip verify` or `vip cleanup` of this
release moves them to the cache folder, or deletes them if it cannot. Never
share those files.

`vip.toml` can hold `api_key` and `password` values. Remove or redact them
before you share a VIP directory. Prefer the `VIP_CONNECT_API_KEY`,
`VIP_WORKBENCH_API_KEY`, and `VIP_TEST_PASSWORD` environment variables over
inline secrets.

## Uninstalling

To reverse what `vip install` (or `just setup`) did:
Expand Down
31 changes: 31 additions & 0 deletions selftests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,37 @@ def _restore_auth_entrypoints():
setattr(_auth, name, func)


_auth_cache_setup_patch_key = pytest.StashKey[pytest.MonkeyPatch]()


@pytest.hookimpl(tryfirst=True)
def pytest_configure(config):
"""Keep outer-session configuration away from the user's credential files."""
patch = pytest.MonkeyPatch()
config.stash[_auth_cache_setup_patch_key] = patch
config.add_cleanup(patch.undo)
patch.setattr("vip.plugin.auth.prepare_auth_cache", lambda **_: None)


@pytest.hookimpl(tryfirst=True)
def pytest_sessionstart(session):
"""Restore cache preparation before selftests and nested pytest runs."""
session.config.stash[_auth_cache_setup_patch_key].undo()


@pytest.fixture(autouse=True)
Comment thread
Copilot marked this conversation as resolved.
Resolved
def _isolated_auth_cache_root(monkeypatch, tmp_path_factory):
"""Point the auth cache root at a temp directory for every selftest.

``vip verify`` and ``vip cleanup`` tidy the real cache (migrate, prune, chmod) on
every run, so a selftest must never resolve the user's own ``~/.cache``. On Windows
``LOCALAPPDATA`` comes before ``XDG_CACHE_HOME``, so it is cleared too. Tests about
the cache root set their own values with ``monkeypatch``.
"""
monkeypatch.delenv("LOCALAPPDATA", raising=False)
monkeypatch.setenv("XDG_CACHE_HOME", str(tmp_path_factory.mktemp("xdg-cache")))


@pytest.fixture(autouse=True)
def _no_ambient_proxy(monkeypatch):
"""Clear proxy environment variables for every selftest.
Expand Down
Loading
Loading