Skip to content

FEAT: Let users pick a server credential for a target (part 19) - #4070

Open
varunj-msft wants to merge 269 commits into
microsoft:mainfrom
varunj-msft:varunj-msft/13178-Server-Credentials
Open

varunj-msft wants to merge 269 commits into
microsoft:mainfrom
varunj-msft:varunj-msft/13178-Server-Credentials

Conversation

@varunj-msft

@varunj-msft varunj-msft commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Description

Part 19 of saving Registry entries across restarts. A side branch stacked on part 9 (#4027), with part 17 (#3984) merged in as the first commit; nothing builds on it. This PR's own changes: varunj-msft/PyRIT@8c19cc7...varunj-msft/13178-Server-Credentials

Design: 4.4 Credentials, 5. How an admin sets up credentials. Where every part fits: PR map.

This is one of the changes for saving Registry entries across restarts. Until the earlier PRs merge, the diff here also shows their changes.

A saved target can't hold a key, so a target that needs an API key could only be Temporary. An administrator can now list keys from the server's environment that users pick by name, each tied to the only endpoint it is sent to.

  • .pyrit_conf takes server_credentials: a list of entries with a name users pick, the env_var that holds the key, and the endpoint the key is sent to. Each name can be listed once. The endpoint must be a full http(s) address with no user name, password, query or fragment.
  • GET /api/targets/types lists each credential's name and endpoint for the types that can use one (the OpenAI targets for now), never the variable or the key.
  • POST /api/targets takes "server_credential": "<name>" with auth_mode api_key and no api_key of its own, and not with source (422 otherwise). The key is used only when the target's endpoint is the credential's endpoint, compared with the scheme and host lowercased and a default port and trailing slash removed. A credential that isn't listed or set, or another endpoint, gets a 400.
  • A saved target stores the credential's name, never the key, and reads the key again at every start, so a rotated value takes effect at the next start. Restore refuses a saved target whose credential is no longer listed or set.
  • The New Target dialog offers Server credential as an authentication choice when the type has one. Picking one sets the endpoint to the credential's endpoint, read-only, sends the name with no key, and lets the target be saved.
  • .pyrit_conf_example, doc/getting_started/pyrit_conf.md, the backend README and the GUI doc describe the setting. They say to list a variable that holds only that key: a variable a target reads on its own, such as OPENAI_CHAT_KEY, can still reach any endpoint through a Temporary target created without a key.

What stays the same: without server_credentials in .pyrit_conf, nothing changes; the types list has empty lists and the dialog offers no new choice. A typed key still makes a Temporary target, and a Temporary target without a key still uses this server's own key variable, as the backend README describes.

Screenshots: the New Target dialog with Server credential chosen, and the saved target in the Targets table.
credentials_1_new_target_server_credential
credentials_2_saved_target_row

Not covered:

# Conflicts:
#	pyrit/prompt_target/azure_blob_storage_target.py
# Conflicts:
#	frontend/e2e/explicit-targets.seeded.spec.ts
#	frontend/src/components/Config/CreateTargetDialog.test.tsx
#	frontend/src/components/Config/CreateTargetDialog.tsx
# Conflicts:
#	tests/unit/backend/test_temporary_components.py
The runtime status keeps its short summary. The restore log now also lists each field's full location
and message, escaped, without the stored values, and with URL credentials removed. Credentials are
removed before a location is shortened, so the summary can't keep part of one either.
# Conflicts:
#	pyrit/registry/registry_recipe_storage.py

This branch has not been deployed

No deployments
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.

3 participants