@ory/claude-code 0.1.2 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -35
- package/dist/cli/main.js +17 -0
- package/dist/handlers.js +75 -36
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,99 +2,189 @@
|
|
|
2
2
|
|
|
3
3
|
[Ory](https://ory.com) bundled into [Claude Code](https://docs.anthropic.com/en/docs/claude-code): skills and slash commands that scaffold Ory authentication into your codebase, a local Ory stack you can spin up in one command, and (when pointed at an Ory project) authentication, authorization, and audit for every tool Claude runs.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
You don't need an Ory account or any prior Ory experience to start.
|
|
6
|
+
|
|
7
|
+
## Prerequisites
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
- [Claude Code](https://docs.anthropic.com/en/docs/claude-code) installed and signed in
|
|
10
|
+
- Node.js **≥ 24**
|
|
11
|
+
- [Docker](https://docs.docker.com/get-docker/) (only needed for the local Ory stack)
|
|
12
|
+
- macOS or Linux. Windows works via WSL2.
|
|
8
13
|
|
|
9
|
-
|
|
14
|
+
## Install
|
|
15
|
+
|
|
16
|
+
Inside Claude Code:
|
|
10
17
|
|
|
11
18
|
```
|
|
12
19
|
/plugin install ory-agent-plugin
|
|
13
20
|
```
|
|
14
21
|
|
|
15
|
-
|
|
22
|
+
That's it — skills, slash commands, hooks, and the Ory MCP server are now registered.
|
|
23
|
+
|
|
24
|
+
<details>
|
|
25
|
+
<summary>Alternative install paths</summary>
|
|
26
|
+
|
|
27
|
+
If the public marketplace install above isn't available, either of these registers the same plugin:
|
|
16
28
|
|
|
17
29
|
```
|
|
30
|
+
# Ory-hosted marketplace
|
|
18
31
|
/plugin marketplace add ory/claude-plugins
|
|
19
32
|
/plugin install ory-agent-plugin@ory-plugins
|
|
20
33
|
```
|
|
21
34
|
|
|
22
|
-
**3. The Ory installer.** No prior `npm install` required:
|
|
23
|
-
|
|
24
35
|
```bash
|
|
36
|
+
# Direct installer, no prior npm install required
|
|
25
37
|
npx @ory/claude-code install # current project
|
|
26
38
|
npx @ory/claude-code install --global # all projects (user scope)
|
|
27
39
|
npx @ory/claude-code uninstall
|
|
28
40
|
```
|
|
29
41
|
|
|
30
|
-
|
|
42
|
+
</details>
|
|
31
43
|
|
|
32
|
-
##
|
|
44
|
+
## Quickstart (≈ 3 minutes)
|
|
33
45
|
|
|
34
|
-
|
|
46
|
+
From any project where you'd like Ory authentication, inside Claude Code:
|
|
35
47
|
|
|
36
|
-
|
|
48
|
+
1. **Start a local Ory instance.** Ask Claude *"start the local Ory stack"* or run:
|
|
49
|
+
|
|
50
|
+
```
|
|
51
|
+
/ory:local-up
|
|
52
|
+
```
|
|
37
53
|
|
|
38
|
-
|
|
54
|
+
A banner prints the seeded test user's email and password. Note them — you'll log in with them in step 3.
|
|
39
55
|
|
|
40
|
-
|
|
41
|
-
- **`/ory:login-flow`**: login, registration, recovery, verification, and settings pages with Ory Elements. Next.js App Router and React SPA variants.
|
|
42
|
-
- **`/ory:social-login`**: Google, GitHub, Apple, Microsoft, Discord, and other OIDC providers with Jsonnet data mappers.
|
|
43
|
-
- **`/ory:local-dev`**: drive the local Ory stack (below) from within Claude to prototype and test against without a remote project.
|
|
56
|
+
2. **Scaffold Ory into your project.** Ask Claude *"add Ory auth to this app"* or run:
|
|
44
57
|
|
|
45
|
-
|
|
58
|
+
```
|
|
59
|
+
/ory:auth-setup
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Claude installs Ory Elements, wires the SDK, generates the login / registration / recovery / verification / settings pages, and sets up session middleware. It targets the local stack from step 1, so no signup or API key is needed.
|
|
63
|
+
|
|
64
|
+
3. **Sign in.** Start your app, visit the login page Claude added, and sign in with the seeded credentials. You now have a real Ory session backed by a real Ory stack — locally, offline, with zero configuration.
|
|
65
|
+
|
|
66
|
+
That's the full Ory DX path. Stop here if you're just evaluating the plugin. Continue to [Agent security](#agent-security) when you're ready to enforce.
|
|
67
|
+
|
|
68
|
+
## What's included
|
|
69
|
+
|
|
70
|
+
### Skills for scaffolding Ory into your application
|
|
71
|
+
|
|
72
|
+
Each skill is a vetted, end-to-end playbook. Ask Claude in natural language or invoke the slash command directly:
|
|
73
|
+
|
|
74
|
+
- **`/ory:auth-setup`** — full project setup. Install the Ory CLI, create an Ory Network project (or use the local one), add Ory Elements, configure the SDK, build the auth pages, wire session middleware.
|
|
75
|
+
- **`/ory:login-flow`** — login, registration, recovery, verification, and settings pages with Ory Elements. Next.js App Router and React SPA variants.
|
|
76
|
+
- **`/ory:social-login`** — Google, GitHub, Apple, Microsoft, Discord, and other OIDC providers with Jsonnet data mappers.
|
|
77
|
+
- **`/ory:local-dev`** — drive the local Ory stack from within Claude to prototype and test without a remote project.
|
|
46
78
|
|
|
47
79
|
### Ory MCP server
|
|
48
80
|
|
|
49
|
-
Bundled and registered automatically.
|
|
81
|
+
Bundled and registered automatically. Exposes the Ory CLI and the Ory Network REST API as MCP tools so Claude can manage identities, OAuth2 clients, projects, permission tuples, and configuration without ever leaving the chat. Useful for seeding test data, verifying a scaffolded integration, or running one-off admin tasks.
|
|
50
82
|
|
|
51
|
-
### Local Ory stack
|
|
83
|
+
### Local Ory stack
|
|
52
84
|
|
|
53
85
|
```
|
|
54
86
|
/ory:local-up # start a local Ory instance in Docker
|
|
55
87
|
/ory:local-down # tear it all down
|
|
56
88
|
```
|
|
57
89
|
|
|
58
|
-
`local
|
|
90
|
+
`local-up` brings up Ory Identities, OAuth2, and Permissions, plus a login UI on `:3000` and Jaeger on `:16686`, all reachable through `http://localhost:4000`. A test user identity is seeded and the credentials are printed for you. Use it to:
|
|
59
91
|
|
|
60
92
|
- **Learn Ory hands-on** without signing up for a hosted project.
|
|
61
|
-
- **Prototype** flows (login, social, MFA, recovery, permission tuples) against a real Ory backend
|
|
93
|
+
- **Prototype** flows (login, social, MFA, recovery, permission tuples) against a real Ory backend.
|
|
62
94
|
- **Test** an auth integration end-to-end before pushing anything to a real environment.
|
|
63
95
|
- **Develop** your application against the same identity, OAuth2, and permission surfaces you'll ship with.
|
|
64
96
|
|
|
65
|
-
|
|
97
|
+
## Pointing at a real Ory project
|
|
66
98
|
|
|
67
|
-
|
|
99
|
+
The Quickstart uses the local stack. If you have a hosted [Ory Network](https://console.ory.sh) project, point the plugin at it:
|
|
68
100
|
|
|
69
101
|
```bash
|
|
70
|
-
npx -y -p @ory/claude-code ory-claude configure
|
|
102
|
+
npx -y -p @ory/claude-code ory-claude configure \
|
|
103
|
+
--project-url https://<id>.projects.oryapis.com \
|
|
104
|
+
--api-key ory_pat_...
|
|
71
105
|
```
|
|
72
106
|
|
|
73
|
-
Config is saved to `~/.config/ory-agent-plugins/config.json` and shared across every Ory agent plugin on the machine.
|
|
107
|
+
Config is saved to `~/.config/ory-agent-plugins/config.json` and shared across every Ory agent plugin on the machine.
|
|
108
|
+
|
|
109
|
+
Without configuration the plugin still loads cleanly and runs in **pass-through mode**: skills and commands work, but nothing is blocked. You can stay in pass-through mode indefinitely if you only want the DX features.
|
|
74
110
|
|
|
75
|
-
## Agent security
|
|
111
|
+
## Agent security
|
|
76
112
|
|
|
77
|
-
Once the plugin is pointed at an Ory project (local or hosted), Claude's session and every tool call
|
|
113
|
+
Once the plugin is pointed at an Ory project (local or hosted), Claude's session and every tool call can be governed by Ory.
|
|
78
114
|
|
|
79
|
-
- **Authentication.** Two identities. The human at the keyboard (the **user**) authenticates interactively via Ory Identities when `ORY_AUTH_GATE=1
|
|
80
|
-
- **Authorization.** Before any tool runs, the plugin checks Ory Permissions against the user's subject and blocks the call on `deny`. MCP tool calls additionally get a server-level check.
|
|
81
|
-
- **Audit.** Every decision (allow, deny, fallback) is recorded as a structured trace span: NDJSON file output and/or OTLP/HTTP export to Jaeger, Honeycomb, Grafana, and similar collectors. The user
|
|
115
|
+
- **Authentication.** Two identities. The human at the keyboard (the **user**) authenticates interactively via Ory Identities when `ORY_AUTH_GATE=1` is set. The Claude process (the **agent**) gets its own OAuth2 identity, self-registered via [Dynamic Client Registration (RFC 7591)](https://datatracker.ietf.org/doc/html/rfc7591) on first run. Sub-agents launched by the `Task` tool each receive their own typed identity.
|
|
116
|
+
- **Authorization.** Before any tool runs, the plugin checks [Ory Permissions](https://www.ory.sh/docs/keto) (Zanzibar-style relation tuples) against the user's subject and blocks the call on `deny`. MCP tool calls additionally get a server-level check.
|
|
117
|
+
- **Audit.** Every decision (allow, deny, fallback) is recorded as a structured trace span: NDJSON file output and/or OTLP/HTTP export to Jaeger, Honeycomb, Grafana, and similar collectors. The user → agent (and agent → subagent) delegation chain is written to Ory as relation tuples so *"agent X acting on behalf of user Y"* stays queryable after tokens expire.
|
|
82
118
|
|
|
83
|
-
The plugin is **fail-open** on its own infrastructure failures (network errors, rate limits, missing config), so enforcement is only as strong as your tuples
|
|
119
|
+
The plugin is **fail-open** on its own infrastructure failures (network errors, rate limits, missing config), so enforcement is only as strong as your tuples — grant explicit `invoke` relations for the tools each user should be able to run.
|
|
84
120
|
|
|
85
|
-
|
|
121
|
+
### Enable enforcement
|
|
122
|
+
|
|
123
|
+
After install the plugin runs in **observe mode**: every tool call is checked against Ory Permissions, but a deny is recorded as a `permission.observe_deny` audit span and the tool runs anyway. This lets you see what *would* be blocked before turning on hard blocking.
|
|
124
|
+
|
|
125
|
+
1. **Turn on the user gate.** In your shell:
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
export ORY_AUTH_GATE=1
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
The next Claude session opens a browser for PKCE login. Subsequent sessions reuse the persisted token until it expires.
|
|
132
|
+
|
|
133
|
+
2. **Bootstrap tuples for the built-in tools.** One idempotent command grants the current user `use` on every tool Claude ships with (Read, Write, Bash, …):
|
|
134
|
+
|
|
135
|
+
```bash
|
|
136
|
+
npx -y -p @ory/claude-code ory-claude permissions bootstrap
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
If a user identity is already cached at install time, the installer runs this for you automatically — re-run after adding tools, switching subjects, or changing the namespace.
|
|
140
|
+
|
|
141
|
+
3. **Check coverage.** `permissions status` probes every tool in the harness's catalog and prints allowed / denied per tool:
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
npx -y -p @ory/claude-code ory-claude permissions status
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
Add tuples for any MCP server tools or custom commands by hand, or via the Ory MCP server from inside Claude (*"grant me use on the Bash tool"*).
|
|
148
|
+
|
|
149
|
+
4. **Promote to enforce.** Once the observe-mode logs look right, switch over:
|
|
150
|
+
|
|
151
|
+
```bash
|
|
152
|
+
npx -y -p @ory/claude-code ory-claude permissions enforce
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Denies now block the tool call; Claude shows the denial reason and the decision is recorded as a `tool.block` trace span with `blocked: true`. Switch back any time with `permissions observe`.
|
|
156
|
+
|
|
157
|
+
## CLI reference
|
|
86
158
|
|
|
87
159
|
```
|
|
88
|
-
npx -y -p @ory/claude-code ory-claude install | uninstall
|
|
89
|
-
npx -y -p @ory/claude-code ory-claude configure
|
|
90
|
-
npx -y -p @ory/claude-code ory-claude agent <status|unregister>
|
|
160
|
+
npx -y -p @ory/claude-code ory-claude install | uninstall [--global]
|
|
161
|
+
npx -y -p @ory/claude-code ory-claude configure [--project-url <url>] [--api-key <key>] [--audit-only]
|
|
162
|
+
npx -y -p @ory/claude-code ory-claude agent <status|unregister> Manage the agent's OAuth2 identity
|
|
163
|
+
npx -y -p @ory/claude-code ory-claude permissions <status|bootstrap|observe|enforce>
|
|
91
164
|
npx -y -p @ory/claude-code ory-claude local <up|down|status|seed|logs|env|configure|reset>
|
|
92
165
|
npx -y -p @ory/claude-code ory-claude status
|
|
93
166
|
```
|
|
94
167
|
|
|
168
|
+
Highlights:
|
|
169
|
+
|
|
170
|
+
- `agent status` — show the current persisted DCR identity for the agent.
|
|
171
|
+
- `permissions observe` / `permissions enforce` — switch between "log denies, allow through" (the install default) and "block denies." `permissions bootstrap` writes `use` tuples for the harness's built-in tools so the promotion path doesn't require hand-writing relationships.
|
|
172
|
+
- `configure --audit-only` — kill switch that disables Ory entirely (no auth, no permission checks; only audit logging of tool invocations). For phased rollouts, prefer `permissions observe` over `--audit-only`.
|
|
173
|
+
- `local seed` / `local env` — reseed the test user, or print env vars for pointing other tools at the local stack.
|
|
174
|
+
|
|
175
|
+
## Troubleshooting
|
|
176
|
+
|
|
177
|
+
- **`/ory:local-up` fails.** Make sure Docker is running and ports `3000`, `4000`, `4100`, and `16686` are free.
|
|
178
|
+
- **PKCE login loops.** Clear persisted state with `npx -y -p @ory/claude-code ory-claude agent unregister` and retry.
|
|
179
|
+
- **`npx` fetches an old version.** Force a fresh fetch: `npx -y -p @ory/claude-code@latest ory-claude …`.
|
|
180
|
+
- **Need more signal.** Set `ORY_AGENT_DEBUG=true` and `ORY_AGENT_LOG_FILE=/tmp/ory.log` to capture structured logs.
|
|
181
|
+
|
|
95
182
|
## Links
|
|
96
183
|
|
|
97
|
-
- [
|
|
184
|
+
- [Ory documentation](https://www.ory.com/docs/)
|
|
185
|
+
- [Ory Network console](https://console.ory.sh)
|
|
186
|
+
- [Ory Elements](https://github.com/ory/elements)
|
|
187
|
+
- [Claude Code documentation](https://docs.anthropic.com/en/docs/claude-code)
|
|
98
188
|
|
|
99
189
|
## License
|
|
100
190
|
|
package/dist/cli/main.js
CHANGED
|
@@ -55,6 +55,10 @@ function main() {
|
|
|
55
55
|
switch (command) {
|
|
56
56
|
case "install":
|
|
57
57
|
(0, setup_js_1.install)(args);
|
|
58
|
+
postInstallPermissions("ory-claude", "claude-code").then(() => process.exit(0), (err) => {
|
|
59
|
+
console.error(err.message ?? err);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
});
|
|
58
62
|
break;
|
|
59
63
|
case "uninstall":
|
|
60
64
|
(0, setup_js_1.uninstall)(args);
|
|
@@ -68,6 +72,12 @@ function main() {
|
|
|
68
72
|
process.exit(1);
|
|
69
73
|
});
|
|
70
74
|
break;
|
|
75
|
+
case "permissions":
|
|
76
|
+
(0, argus_1.runPermissionsCommand)("ory-claude", "claude-code", args).then((code) => process.exit(code), (err) => {
|
|
77
|
+
console.error(err.message ?? err);
|
|
78
|
+
process.exit(1);
|
|
79
|
+
});
|
|
80
|
+
break;
|
|
71
81
|
case "status":
|
|
72
82
|
status();
|
|
73
83
|
break;
|
|
@@ -89,6 +99,12 @@ function main() {
|
|
|
89
99
|
process.exit(1);
|
|
90
100
|
}
|
|
91
101
|
}
|
|
102
|
+
async function postInstallPermissions(binName, harness) {
|
|
103
|
+
const bootstrapped = await (0, argus_1.maybeAutoBootstrap)(binName, harness);
|
|
104
|
+
(0, argus_1.printPermissionsOnboardingHelp)(binName, harness, {
|
|
105
|
+
bootstrappedAutomatically: bootstrapped,
|
|
106
|
+
});
|
|
107
|
+
}
|
|
92
108
|
function status() {
|
|
93
109
|
console.log("Ory Agent Plugin Status (Claude Code)");
|
|
94
110
|
console.log("======================================");
|
|
@@ -116,6 +132,7 @@ Commands:
|
|
|
116
132
|
install [--global] Install Ory plugin via claude CLI marketplace
|
|
117
133
|
uninstall [--global] Remove Ory plugin and marketplace
|
|
118
134
|
configure Set or view Ory project URL and API key
|
|
135
|
+
permissions <cmd> Manage permission mode and tool tuples (status, bootstrap, observe, enforce)
|
|
119
136
|
status Show plugin status and configuration
|
|
120
137
|
local <cmd> Manage local Ory dev environment (up, down, status, seed, ...)
|
|
121
138
|
|
package/dist/handlers.js
CHANGED
|
@@ -188,40 +188,65 @@ async function handlePreToolUse(input, client, deps = {}) {
|
|
|
188
188
|
subject,
|
|
189
189
|
spanAttributes: { toolName },
|
|
190
190
|
});
|
|
191
|
-
|
|
191
|
+
const mcpAttrs = {
|
|
192
|
+
toolName,
|
|
193
|
+
mcpServer: mcpTool.serverName,
|
|
194
|
+
mcpTool: mcpTool.toolName,
|
|
195
|
+
...inputSummary,
|
|
196
|
+
};
|
|
197
|
+
const decision = (0, argus_1.applyPermissionMode)(client, mcpResult.allowed, {
|
|
198
|
+
object: mcpTool.serverName,
|
|
199
|
+
relation: "use",
|
|
200
|
+
subjectId,
|
|
201
|
+
spanAttributes: mcpAttrs,
|
|
202
|
+
});
|
|
203
|
+
if (decision.kind === "allow") {
|
|
204
|
+
client.tracer.record("tool.invoke", "ok", { attributes: mcpAttrs });
|
|
205
|
+
return {};
|
|
206
|
+
}
|
|
207
|
+
if (decision.kind === "observe") {
|
|
192
208
|
client.tracer.record("tool.block", "denied", {
|
|
193
|
-
attributes: {
|
|
209
|
+
attributes: { ...mcpAttrs, allowed: false, ...(0, argus_1.alertAttributes)(false) },
|
|
210
|
+
});
|
|
211
|
+
client.tracer.record("tool.invoke", "ok", {
|
|
212
|
+
attributes: { ...mcpAttrs, allowed: false, observed: true },
|
|
194
213
|
});
|
|
195
|
-
return {
|
|
196
|
-
decision: "block",
|
|
197
|
-
reason: (0, argus_1.formatDenialMessage)({ tool: toolName, subjectId, mcp: mcpTool }),
|
|
198
|
-
};
|
|
214
|
+
return {};
|
|
199
215
|
}
|
|
200
|
-
client.tracer.record("tool.invoke", "ok", {
|
|
201
|
-
attributes: { toolName, mcpServer: mcpTool.serverName, mcpTool: mcpTool.toolName, ...inputSummary },
|
|
202
|
-
});
|
|
203
|
-
return {};
|
|
204
|
-
}
|
|
205
|
-
const namespace = resolveNamespace();
|
|
206
|
-
const result = await client.checkPermission({
|
|
207
|
-
namespace,
|
|
208
|
-
object: toolName,
|
|
209
|
-
relation: "use",
|
|
210
|
-
...subject,
|
|
211
|
-
}, { spanAttributes: { toolName } });
|
|
212
|
-
if (!result.allowed) {
|
|
213
216
|
client.tracer.record("tool.block", "denied", {
|
|
214
|
-
attributes: {
|
|
217
|
+
attributes: { ...mcpAttrs, allowed: false, ...(0, argus_1.alertAttributes)(true) },
|
|
215
218
|
});
|
|
216
219
|
return {
|
|
217
220
|
decision: "block",
|
|
218
|
-
reason: (0, argus_1.formatDenialMessage)({ tool: toolName, subjectId,
|
|
221
|
+
reason: (0, argus_1.formatDenialMessage)({ tool: toolName, subjectId, mcp: mcpTool }),
|
|
219
222
|
};
|
|
220
223
|
}
|
|
221
|
-
|
|
222
|
-
|
|
224
|
+
const namespace = resolveNamespace();
|
|
225
|
+
const decision = await (0, argus_1.checkAndDecide)(client, { namespace, object: toolName, relation: "use", ...subject }, { spanAttributes: { toolName } });
|
|
226
|
+
if (decision.kind === "fail_open") {
|
|
227
|
+
return handlePermissionError(decision.error, toolName, client);
|
|
228
|
+
}
|
|
229
|
+
const attrs = { toolName, ...inputSummary };
|
|
230
|
+
if (decision.kind === "allow") {
|
|
231
|
+
client.tracer.record("tool.invoke", "ok", { attributes: { ...attrs, allowed: true } });
|
|
232
|
+
return {};
|
|
233
|
+
}
|
|
234
|
+
if (decision.kind === "observe") {
|
|
235
|
+
client.tracer.record("tool.block", "denied", {
|
|
236
|
+
attributes: { ...attrs, allowed: false, ...(0, argus_1.alertAttributes)(false) },
|
|
237
|
+
});
|
|
238
|
+
client.tracer.record("tool.invoke", "ok", {
|
|
239
|
+
attributes: { ...attrs, allowed: false, observed: true },
|
|
240
|
+
});
|
|
241
|
+
return {};
|
|
242
|
+
}
|
|
243
|
+
client.tracer.record("tool.block", "denied", {
|
|
244
|
+
attributes: { ...attrs, allowed: false, ...(0, argus_1.alertAttributes)(true) },
|
|
223
245
|
});
|
|
224
|
-
return {
|
|
246
|
+
return {
|
|
247
|
+
decision: "block",
|
|
248
|
+
reason: (0, argus_1.formatDenialMessage)({ tool: toolName, subjectId, namespace }),
|
|
249
|
+
};
|
|
225
250
|
}
|
|
226
251
|
catch (err) {
|
|
227
252
|
return handlePermissionError(err, toolName, client);
|
|
@@ -354,20 +379,34 @@ async function handlePermissionRequest(input, client) {
|
|
|
354
379
|
subject,
|
|
355
380
|
spanAttributes: { toolName },
|
|
356
381
|
});
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
:
|
|
382
|
+
const decision = (0, argus_1.applyPermissionMode)(client, mcpResult.allowed, {
|
|
383
|
+
object: mcpTool.serverName,
|
|
384
|
+
relation: "use",
|
|
385
|
+
subjectId,
|
|
386
|
+
spanAttributes: { toolName, mcpServer: mcpTool.serverName, mcpTool: mcpTool.toolName },
|
|
387
|
+
});
|
|
388
|
+
if (decision.kind === "deny") {
|
|
389
|
+
return permissionRequestDecision("deny", (0, argus_1.formatDenialMessage)({ tool: toolName, subjectId, mcp: mcpTool }));
|
|
390
|
+
}
|
|
391
|
+
return permissionRequestDecision("allow", decision.kind === "observe"
|
|
392
|
+
? "Ory observe mode — denied by policy but allowed through"
|
|
393
|
+
: "Ory MCP server permission granted");
|
|
360
394
|
}
|
|
361
395
|
const namespace = resolveNamespace();
|
|
362
|
-
const
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
396
|
+
const decision = await (0, argus_1.checkAndDecide)(client, { namespace, object: toolName, relation: "use", ...subject }, { spanAttributes: { toolName } });
|
|
397
|
+
if (decision.kind === "fail_open") {
|
|
398
|
+
const code = decision.error.code;
|
|
399
|
+
const fallbackReason = code === "network_error" || code === "rate_limited"
|
|
400
|
+
? `Ory unavailable (${code}), falling back to user prompt`
|
|
401
|
+
: `Ory permission check failed: ${decision.error.message}`;
|
|
402
|
+
return permissionRequestFallback(fallbackReason);
|
|
403
|
+
}
|
|
404
|
+
if (decision.kind === "deny") {
|
|
405
|
+
return permissionRequestDecision("deny", (0, argus_1.formatDenialMessage)({ tool: toolName, subjectId, namespace }));
|
|
406
|
+
}
|
|
407
|
+
return permissionRequestDecision("allow", decision.kind === "observe"
|
|
408
|
+
? "Ory observe mode — denied by policy but allowed through"
|
|
409
|
+
: "Ory permission granted");
|
|
371
410
|
}
|
|
372
411
|
catch (err) {
|
|
373
412
|
const oryErr = err;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ory/claude-code",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Ory plugin for Claude Code: scaffolding skills, a local Ory instance, and authentication, authorization, and audit for every tool call",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://ory.com",
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
"!dist/**/*.tsbuildinfo"
|
|
73
73
|
],
|
|
74
74
|
"dependencies": {
|
|
75
|
-
"@ory/argus": "0.
|
|
75
|
+
"@ory/argus": "0.2.0"
|
|
76
76
|
},
|
|
77
77
|
"engines": {
|
|
78
78
|
"node": ">=24"
|