Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
8c7c8fc
FEAT: Keep submitted target keys per caller in the backend
richlundeen Nov 7, 2026
78a9469
Merge pinned main into caller credential PR
richlundeen Nov 7, 2026
fdbc2fe
Fix caller credential isolation and target deletion lifecycle
richlundeen Nov 7, 2026
9ccc630
FEAT: Make per-caller target credentials opt-in
richlundeen Nov 7, 2026
2513584
Cover request-level auth overrides and prefixed target deletion
richlundeen Nov 7, 2026
9dfc409
Merge concurrent personal-target opt-in changes
richlundeen Nov 7, 2026
20c2361
Narrow runtime routing fixture parameters for strict type checks
richlundeen Nov 7, 2026
c9cc905
Preserve separate LiteLLM decision token-provider contract
richlundeen Nov 7, 2026
0e75165
FEAT: Add CLI token client and personal copies of existing targets
richlundeen Nov 7, 2026
3f2cb65
DOC: Diagram personal target credential flow
richlundeen Nov 9, 2026
6405408
DOC: Simplify caller credential diagram around request flow
richlundeen Nov 9, 2026
8bab183
Merge pinned main into PR 4024 preserving caller credentials
richlundeen Nov 9, 2026
73d5260
Fix credential tests for public import contract
richlundeen Nov 9, 2026
5f1cb7a
Merge main 3e4d7d4a7 into PR 4024 preserving caller credentials
richlundeen Nov 13, 2026
74fdf6b
Scope caller-credential rules to backend providers and close personal…
richlundeen Nov 13, 2026
612391a
Merge main 4f6f4a007 into PR 4024
richlundeen Nov 16, 2026
a017a1a
Use each caller's own key through auth_mode "caller"; drop copies and…
richlundeen Nov 16, 2026
e8adeb7
Show whose account each target uses and let callers set their own key…
richlundeen Nov 16, 2026
c5bdc9b
Explain the key field for each user's own key in the create dialog
richlundeen Nov 16, 2026
ca390f0
Keep server headers and composites from bypassing each caller's own key
richlundeen Nov 16, 2026
4a869fd
Replace each caller's own key with private targets owned by one user
richlundeen Nov 17, 2026
c6dd3bb
Merge main 5325d9712 into PR 4024
richlundeen Nov 17, 2026
ec89b96
Fix the end of the create dialog test file
richlundeen Nov 17, 2026
2aa7a9e
Ask who can use a new target after its sign-in settings
richlundeen Nov 17, 2026
9b0223b
Test that another user can't send through someone's private target
richlundeen Nov 17, 2026
354165b
Merge main 83e7748fe into PR 4024 preserving private targets and save…
richlundeen Nov 17, 2026
7dc25c8
Update target credentials in place, only where the creator allowed it
richlundeen Nov 17, 2026
f6078ce
Keep token-provider targets on their provider when their credentials …
richlundeen Nov 17, 2026
c722759
Merge pinned main into the private targets PR
richlundeen Nov 18, 2026
4323645
Fix typing in private target and credential status tests
richlundeen Nov 18, 2026
b635a68
Merge main into private target credentials
richlundeen Nov 18, 2026
25f2413
Harden private target credential updates and launch conflicts
richlundeen Nov 18, 2026
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
4 changes: 3 additions & 1 deletion doc/code/framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ These modules support every component.
- Build every component that comes from user input (configuration, REST, or the CLI) through the registry, and store reusable instances there.
- Construction doesn't require registration; the caller owns temporary instances.
- Accept only explicitly supported external inputs, and leave argument validation to constructors.
- Show an entry that is private to its owner only to that owner. To everyone else, it doesn't exist.

## [Normalizers](./targets/11_message_normalizer)

Expand Down Expand Up @@ -327,6 +328,7 @@ The backend is an adapter, not a second library. It owns HTTP and process concer
- **Don't add domain models.** `pyrit/backend/models` holds backend-only envelopes, such as pagination and presentation views, built from `pyrit.models` types. If a backend model or a service's dataclass would describe a domain concept, put it in `pyrit.models` instead.
- Keep each layer thin. Routes and middleware handle HTTP, services call the library for a request, and mappers translate library objects into API views. None of them make domain decisions.
- Build components through the registry and persist through memory, as everywhere else.
- The auth middleware scopes each request, and the work it starts, to its caller. Work that starts outside its request, such as a queued run, carries the caller captured when it was admitted.

**Framework Plans**:

Expand Down Expand Up @@ -362,7 +364,7 @@ These patterns cut across components. Use them instead of inventing a local vari
- **Resolve defaults in one order.** An explicit argument wins, then an initializer default (`@apply_defaults`), then the environment variable that the class names, read at construction, then a declared default or an error. Components don't read `os.environ` anywhere else; setup, the backend, and the CLI read process settings at startup.
- **Give data PyRIT queries a typed field.** If memory queries, filters, or sorts by a value, make it a typed field on the narrowest model that owns it (`MessagePiece`, not `Message`). Other structured data travels in metadata through a value object (below). Labels are user tags: PyRIT stores and filters them for users but never derives behavior from them.
- **Let one value object own each metadata key.** A small model in `pyrit.models` declares a namespaced key and is the only code that reads or writes it, through `to_metadata()` and `from_metadata()`; see `ToolExecutionMetadata`. A missing key, or a legacy value from older rows, reads as unset.
- **Keep shared components free of per-call state.** Registered targets, converters, and scorers serve concurrent callers, so instance state must be safe to share: configuration, caches, clients, and maps keyed by conversation or attempt are fine. Keep per-call data in arguments, the attack context, or memory.
- **Keep shared components free of per-call state.** Registered targets, converters, and scorers serve concurrent callers, so instance state must be safe to share: configuration, caches, clients, and maps keyed by conversation or attempt are fine. Keep per-call data in arguments, the attack context, or memory. The one exception is the caller's identity, which travels in the caller scope (`pyrit.auth.caller_principal_scope`) so the registry can limit private entries to their owner.
- **Keep helper-model prompts in YAML seeds.** Prompts for judges, converters, and adversarial chat are YAML `SeedPrompt`s that declare their parameters. Render them only through `SeedPrompt`'s sandboxed rendering, never with f-strings or `str.format`; per-call content, such as the text being judged, can be plain message text.
- **Declare structured output, and parse it once.** When you need JSON from a model, ask for it with `JsonResponseConfig`, and let the target enforce or adapt it. Parse each kind of response in one function that raises `InvalidJsonException`, and retry through `send_json_with_retry_async`, which starts each retry from a clean history.
- **Store media through serializers.** Write media and other files that results reference only through `data_serializer_factory` into results storage, point to them by the returned path or URL, and read them back the same way. Don't persist base64, temporary files, or paths outside results storage.
Expand Down
28 changes: 27 additions & 1 deletion doc/scanner/1_pyrit_scan.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1436,6 +1436,32 @@
"cell_type": "markdown",
"id": "16",
"metadata": {},
"source": [
"## Updating a Target's Key\n",
"\n",
"A target you create through the API with `\"private\": true` is private: only you can see and use it, and `list-targets` shows it as `Account: Yours`. A private target allows credential updates, so when its key expires or changes, replace it with `set-target-credential`. A shared target allows them only when whoever created it, or the server's configuration, said so; then anyone signed in can update it, and everyone's requests use the new value. `list-targets` shows `Credential updates: allowed` for the targets you can update, and notes when the provider rejected a target's credentials on its last request. The value comes from a hidden prompt (`--prompt`), an environment variable (`--from-env VAR`), or the Anthropic `ant` CLI (`--from-ant`); it is never a command-line value. Add `--header NAME` to set it as a request header instead of the API key, such as a team gateway's own header, `Authorization`, or `Cookie`.\n",
"\n",
"```shell\n",
"# One-time sign-in to the Claude Console for a workspace\n",
"ant auth login --profile copyrit --workspace-id <workspace_id>\n",
"\n",
"# Replace the key with your token, and re-send a fresh one every 15 minutes until Ctrl+C\n",
"pyrit_scan set-target-credential claude --from-ant --ant-profile copyrit --keep-fresh\n",
"\n",
"# Or replace it with an API key from an environment variable\n",
"pyrit_scan set-target-credential claude --from-env ANTHROPIC_API_KEY\n",
"\n",
"# Or set a request header, such as a gateway token, from a hidden prompt\n",
"pyrit_scan set-target-credential team-model --prompt --header X-Team-Token\n",
"```\n",
"\n",
"`--keep-fresh` only replaces expiring `ant` tokens, and it stops when the target is gone or another target took its name, for example after the backend restarts."
]
},
{
"cell_type": "markdown",
"id": "17",
"metadata": {},
"source": [
"## Stopping the Backend Server\n",
"\n",
Expand All @@ -1445,7 +1471,7 @@
{
"cell_type": "code",
"execution_count": null,
"id": "17",
"id": "18",
"metadata": {},
"outputs": [
{
Expand Down
21 changes: 21 additions & 0 deletions doc/scanner/1_pyrit_scan.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,27 @@ async def _build_atomic_attacks_async(self, *, context):
# pyrit_scan scenario-results <id> --view conversations --limit 3
# ```

# %% [markdown]
# ## Updating a Target's Key
#
# A target you create through the API with `"private": true` is private: only you can see and use it, and `list-targets` shows it as `Account: Yours`. A private target allows credential updates, so when its key expires or changes, replace it with `set-target-credential`. A shared target allows them only when whoever created it, or the server's configuration, said so; then anyone signed in can update it, and everyone's requests use the new value. `list-targets` shows `Credential updates: allowed` for the targets you can update, and notes when the provider rejected a target's credentials on its last request. The value comes from a hidden prompt (`--prompt`), an environment variable (`--from-env VAR`), or the Anthropic `ant` CLI (`--from-ant`); it is never a command-line value. Add `--header NAME` to set it as a request header instead of the API key, such as a team gateway's own header, `Authorization`, or `Cookie`.
#
# ```shell
# # One-time sign-in to the Claude Console for a workspace
# ant auth login --profile copyrit --workspace-id <workspace_id>
#
# # Replace the key with your token, and re-send a fresh one every 15 minutes until Ctrl+C
# pyrit_scan set-target-credential claude --from-ant --ant-profile copyrit --keep-fresh
#
# # Or replace it with an API key from an environment variable
# pyrit_scan set-target-credential claude --from-env ANTHROPIC_API_KEY
#
# # Or set a request header, such as a gateway token, from a hidden prompt
# pyrit_scan set-target-credential team-model --prompt --header X-Team-Token
# ```
#
# `--keep-fresh` only replaces expiring `ant` tokens, and it stops when the target is gone or another target took its name, for example after the backend restarts.

# %% [markdown]
# ## Stopping the Backend Server
#
Expand Down
Loading
Loading