feat: harden install and resumable OAuth login
This commit is contained in:
+44
-1
@@ -23,8 +23,18 @@ function fakeAuthService(): AuthService {
|
||||
return {
|
||||
start: async () => ({
|
||||
status: "authorization_pending",
|
||||
authorization_type: "oauth_device_user_verification",
|
||||
login_url: "https://justconn.top/idpOAuth/device?user_code=TEST-CODE",
|
||||
verification_uri_complete: "https://justconn.top/idpOAuth/device?user_code=TEST-CODE",
|
||||
user_code: "TEST-CODE",
|
||||
intended_recipient: "requesting_user",
|
||||
delivery_channel: "current_private_conversation",
|
||||
shareable_with_requesting_user: true,
|
||||
private_conversation_required: true,
|
||||
public_sharing_allowed: false,
|
||||
contains_bearer_credentials: false,
|
||||
contains_device_code: false,
|
||||
remote_desktop_required: false,
|
||||
}),
|
||||
status: async () => ({ status: "login_required" }),
|
||||
};
|
||||
@@ -85,6 +95,25 @@ test("read-only server exposes CRM tools plus browser login tools", async () =>
|
||||
}
|
||||
});
|
||||
|
||||
test("login tools require a private user handoff instead of headless remote desktop", async () => {
|
||||
const connection = await connected(true);
|
||||
try {
|
||||
const tools = (await connection.client.listTools()).tools;
|
||||
const login = tools.find((tool) => tool.name === "nocobase_login");
|
||||
const status = tools.find((tool) => tool.name === "nocobase_login_status");
|
||||
assert.ok(login?.description);
|
||||
assert.ok(status?.description);
|
||||
assert.match(login.description, /MUST deliver login_url and user_code/);
|
||||
assert.match(login.description, /current private conversation/);
|
||||
assert.match(login.description, /headless server/);
|
||||
assert.match(login.description, /remote desktop is not required/);
|
||||
assert.match(login.description, /Never post them publicly/);
|
||||
assert.match(status.description, /private-delivery policy/);
|
||||
} finally {
|
||||
await connection.close();
|
||||
}
|
||||
});
|
||||
|
||||
test("authentication failures tell the Agent to use the MCP browser login flow", async () => {
|
||||
const service = {
|
||||
crmHealth: async () => {
|
||||
@@ -114,10 +143,24 @@ test("browser login tool returns only the safe user-facing authorization fields"
|
||||
});
|
||||
assert.deepEqual(result.structuredContent, {
|
||||
status: "authorization_pending",
|
||||
authorization_type: "oauth_device_user_verification",
|
||||
login_url: "https://justconn.top/idpOAuth/device?user_code=TEST-CODE",
|
||||
verification_uri_complete: "https://justconn.top/idpOAuth/device?user_code=TEST-CODE",
|
||||
user_code: "TEST-CODE",
|
||||
intended_recipient: "requesting_user",
|
||||
delivery_channel: "current_private_conversation",
|
||||
shareable_with_requesting_user: true,
|
||||
private_conversation_required: true,
|
||||
public_sharing_allowed: false,
|
||||
contains_bearer_credentials: false,
|
||||
contains_device_code: false,
|
||||
remote_desktop_required: false,
|
||||
});
|
||||
assert.doesNotMatch(JSON.stringify(result), /access.token|refresh.token|device.code/i);
|
||||
const payload = result.structuredContent as Record<string, unknown>;
|
||||
assert.equal(Object.hasOwn(payload, "access_token"), false);
|
||||
assert.equal(Object.hasOwn(payload, "refresh_token"), false);
|
||||
assert.equal(Object.hasOwn(payload, "device_code"), false);
|
||||
assert.equal(Object.hasOwn(payload, "password"), false);
|
||||
} finally {
|
||||
await connection.close();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user