@pexis/auth 0.0.0-stage → 0.1.1
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/LICENSE +23 -0
- package/README.md +31 -2
- package/dist/index.d.ts +52 -0
- package/dist/index.js +363 -0
- package/dist/index.js.map +1 -0
- package/dist/jwt.d.ts +62 -0
- package/dist/jwt.js +140 -0
- package/dist/jwt.js.map +1 -0
- package/dist/providers.d.ts +81 -0
- package/dist/providers.js +164 -0
- package/dist/providers.js.map +1 -0
- package/dist/server/client.d.ts +48 -0
- package/dist/server/client.js +208 -0
- package/dist/server/client.js.map +1 -0
- package/dist/server/index.d.ts +3 -0
- package/dist/server/index.js +7 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/plugin.d.ts +37 -0
- package/dist/server/plugin.js +522 -0
- package/dist/server/plugin.js.map +1 -0
- package/dist/server/store.d.ts +81 -0
- package/dist/server/store.js +106 -0
- package/dist/server/store.js.map +1 -0
- package/package.json +38 -4
|
@@ -0,0 +1,522 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "@pexis/core/jsx-runtime";
|
|
2
|
+
// oauthServer(): the site as its own OAuth 2.1 authorization server, so MCP
|
|
3
|
+
// clients sign in as a person (MCP authorization, revision 2026-07-28).
|
|
4
|
+
// The design and its independent review are summarized in ARCHITECTURE.md.
|
|
5
|
+
//
|
|
6
|
+
// The rules that matter most:
|
|
7
|
+
// - a token is checked only on the resource it was issued for (/pexis/mcp),
|
|
8
|
+
// and identity reaches actions in process (Connection.agent), never as a
|
|
9
|
+
// header another route could accept;
|
|
10
|
+
// - only clients the app lists may sign in;
|
|
11
|
+
// - nothing before the person presses a button redirects, so the authorize
|
|
12
|
+
// URL is never an open redirector;
|
|
13
|
+
// - consent needs the person's session in a real browser navigation.
|
|
14
|
+
import { BodyError, defineAction, definePage, definePlugin, field, rateLimiter, readBodyText, redirect, } from '@pexis/core';
|
|
15
|
+
import { signedInWithin } from '@pexis/sessions';
|
|
16
|
+
import { requireRecentSignIn, requireUser } from '../index.js';
|
|
17
|
+
import { ClientError, clientIdUrl, clientLoader, isLoopback, redirectAllowed, webMetadataFetch } from './client.js';
|
|
18
|
+
import { hashSecret, memoryOAuthStore, newSecret } from './store.js';
|
|
19
|
+
export const SCOPES = ['actions:read', 'actions:write'];
|
|
20
|
+
const SCOPE_TEXT = {
|
|
21
|
+
'actions:read': 'Look things up on this site as you (searches and other actions that change nothing).',
|
|
22
|
+
'actions:write': 'Make changes on this site as you. Anything that needs your approval still asks you first, on this site.',
|
|
23
|
+
};
|
|
24
|
+
const ACCESS_SECONDS = 15 * 60;
|
|
25
|
+
const CODE_SECONDS = 60;
|
|
26
|
+
const PENDING_SECONDS = 10 * 60;
|
|
27
|
+
const MAX_PENDING = 5;
|
|
28
|
+
const PENDING_KEY = 'pexis.oauth.pending';
|
|
29
|
+
const USER_CACHE_MS = 60_000;
|
|
30
|
+
const DAY_MS = 24 * 60 * 60 * 1000;
|
|
31
|
+
const isObject = (v) => typeof v === 'object' && v !== null && !Array.isArray(v);
|
|
32
|
+
const noStore = { 'cache-control': 'no-store', pragma: 'no-cache' };
|
|
33
|
+
const tokenJson = (body, status = 200, extra = {}) => new Response(JSON.stringify(body), { status, headers: { 'content-type': 'application/json; charset=utf-8', ...noStore, ...extra } });
|
|
34
|
+
const oauthError = (error, description, status = 400) => tokenJson({ error, error_description: description }, status);
|
|
35
|
+
async function s256(verifier) {
|
|
36
|
+
const digest = new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(verifier)));
|
|
37
|
+
return btoa(String.fromCharCode(...digest)).replaceAll('+', '-').replaceAll('/', '_').replace(/=+$/, '');
|
|
38
|
+
}
|
|
39
|
+
/** Constant-time comparison of two short strings. */
|
|
40
|
+
function same(a, b) {
|
|
41
|
+
if (a.length !== b.length)
|
|
42
|
+
return false;
|
|
43
|
+
let diff = 0;
|
|
44
|
+
for (let i = 0; i < a.length; i++)
|
|
45
|
+
diff |= a.charCodeAt(i) ^ b.charCodeAt(i);
|
|
46
|
+
return diff === 0;
|
|
47
|
+
}
|
|
48
|
+
/** The Bearer token in an Authorization header, or null. Other schemes (Basic) are not ours. */
|
|
49
|
+
export function bearerToken(request) {
|
|
50
|
+
const header = request.headers.get('authorization');
|
|
51
|
+
const match = header ? /^Bearer +([A-Za-z0-9._~+/-]+=*) *$/i.exec(header) : null;
|
|
52
|
+
return match ? match[1] : null;
|
|
53
|
+
}
|
|
54
|
+
/** Changes a directive of a Content-Security-Policy header. */
|
|
55
|
+
function withDirective(csp, directive, sources) {
|
|
56
|
+
const parts = csp
|
|
57
|
+
.split(';')
|
|
58
|
+
.map((p) => p.trim())
|
|
59
|
+
.filter((p) => p && !p.startsWith(`${directive} `) && p !== directive);
|
|
60
|
+
return [...parts, `${directive} ${sources}`].join('; ');
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Lets MCP clients sign in as a person with OAuth 2.1, so they can call
|
|
64
|
+
* actions that need a permission. Needs sessions() and auth().
|
|
65
|
+
*
|
|
66
|
+
* @experimental Still being designed: may change, or go, without a deprecation period.
|
|
67
|
+
*/
|
|
68
|
+
export function oauthServer(options) {
|
|
69
|
+
if (typeof options.loadUser !== 'function')
|
|
70
|
+
throw new Error('oauthServer(): loadUser is required, so a grant always acts for the account as it is now.');
|
|
71
|
+
if (options.clients !== 'any' && !Array.isArray(options.clients))
|
|
72
|
+
throw new Error("oauthServer(): clients must list client_id URLs or hosts, or be 'any'.");
|
|
73
|
+
if (options.clients === 'any' && !options.fetchMetadata) {
|
|
74
|
+
throw new Error("oauthServer({ clients: 'any' }) needs fetchMetadata: publicFetch from @pexis/node/public-fetch, which refuses private addresses. Or list the clients you allow.");
|
|
75
|
+
}
|
|
76
|
+
const store = options.store ?? memoryOAuthStore();
|
|
77
|
+
const loader = clientLoader({ fetch: options.fetchMetadata ?? webMetadataFetch });
|
|
78
|
+
const grantMs = (options.grantDays ?? 30) * DAY_MS;
|
|
79
|
+
if (!(grantMs > 0) || grantMs > 90 * DAY_MS)
|
|
80
|
+
throw new Error('oauthServer({ grantDays }) must be more than 0 and at most 90.');
|
|
81
|
+
const connectedAppsPath = options.connectedAppsPath ?? '/account/connected-apps';
|
|
82
|
+
const resourcePath = options.resourcePath ?? '/pexis/mcp';
|
|
83
|
+
const allowed = (clientId) => {
|
|
84
|
+
if (options.clients === 'any')
|
|
85
|
+
return true;
|
|
86
|
+
let host;
|
|
87
|
+
try {
|
|
88
|
+
host = new URL(clientId).hostname;
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
return false;
|
|
92
|
+
}
|
|
93
|
+
return options.clients.some((entry) => entry === clientId || (!entry.includes('/') && entry.toLowerCase() === host));
|
|
94
|
+
};
|
|
95
|
+
const tokenLimiter = rateLimiter({ limit: 30, windowSeconds: 60 });
|
|
96
|
+
const authorizeLimiter = rateLimiter({ limit: 30, windowSeconds: 60 });
|
|
97
|
+
const users = new Map();
|
|
98
|
+
async function currentUser(id) {
|
|
99
|
+
const cached = users.get(id);
|
|
100
|
+
if (cached && Date.now() - cached.at < USER_CACHE_MS)
|
|
101
|
+
return cached.user;
|
|
102
|
+
const user = await options.loadUser(id);
|
|
103
|
+
users.set(id, { at: Date.now(), user });
|
|
104
|
+
if (users.size > 10_000)
|
|
105
|
+
users.delete(users.keys().next().value);
|
|
106
|
+
return user;
|
|
107
|
+
}
|
|
108
|
+
return definePlugin({
|
|
109
|
+
name: 'oauth-server',
|
|
110
|
+
requires: ['sessions'],
|
|
111
|
+
setup(api) {
|
|
112
|
+
if (!options.store)
|
|
113
|
+
api.memoryState('MCP and OAuth sign-in grants', 'oauthServer({ store: oauthStore(db) })');
|
|
114
|
+
const origin = new URL(api.config.origin).origin;
|
|
115
|
+
const issuer = origin;
|
|
116
|
+
const resource = `${origin}${resourcePath}`;
|
|
117
|
+
const resourceMetadataUrl = `${origin}/.well-known/oauth-protected-resource${resourcePath}`;
|
|
118
|
+
api.noPrefetch('/oauth/');
|
|
119
|
+
// --- Discovery ------------------------------------------------------------
|
|
120
|
+
const protectedResource = () => tokenJson({ resource, authorization_servers: [issuer], scopes_supported: [...SCOPES], bearer_methods_supported: ['header'] }, 200, { 'cache-control': 'public, max-age=3600' });
|
|
121
|
+
api.route('GET', `/.well-known/oauth-protected-resource${resourcePath}`, protectedResource);
|
|
122
|
+
api.route('GET', '/.well-known/oauth-protected-resource', protectedResource);
|
|
123
|
+
api.route('GET', '/.well-known/oauth-authorization-server', () => tokenJson({
|
|
124
|
+
issuer,
|
|
125
|
+
authorization_endpoint: `${origin}/oauth/authorize`,
|
|
126
|
+
token_endpoint: `${origin}/oauth/token`,
|
|
127
|
+
revocation_endpoint: `${origin}/oauth/revoke`,
|
|
128
|
+
response_types_supported: ['code'],
|
|
129
|
+
grant_types_supported: ['authorization_code', 'refresh_token'],
|
|
130
|
+
code_challenge_methods_supported: ['S256'],
|
|
131
|
+
token_endpoint_auth_methods_supported: ['none'],
|
|
132
|
+
revocation_endpoint_auth_methods_supported: ['none'],
|
|
133
|
+
scopes_supported: [...SCOPES],
|
|
134
|
+
client_id_metadata_document_supported: true,
|
|
135
|
+
authorization_response_iss_parameter_supported: true,
|
|
136
|
+
}, 200, { 'cache-control': 'public, max-age=3600' }));
|
|
137
|
+
// --- Checking tokens, on the resource only ------------------------------------
|
|
138
|
+
async function check(token) {
|
|
139
|
+
const now = Date.now();
|
|
140
|
+
const access = await store.access(await hashSecret(token), now);
|
|
141
|
+
if (!access)
|
|
142
|
+
return null;
|
|
143
|
+
const grant = await store.getGrant(access.grantId);
|
|
144
|
+
if (!grant || grant.revokedAt !== null || grant.expiresAt <= now)
|
|
145
|
+
return null;
|
|
146
|
+
const user = await currentUser(grant.userId);
|
|
147
|
+
if (!user || user.id !== grant.userId) {
|
|
148
|
+
await store.revoke(grant.id, now);
|
|
149
|
+
return null;
|
|
150
|
+
}
|
|
151
|
+
await store.touch(grant.id, now);
|
|
152
|
+
return { user, clientId: grant.clientId, scopes: [...grant.scopes], grantId: grant.id };
|
|
153
|
+
}
|
|
154
|
+
api.use(async (ctx, next) => {
|
|
155
|
+
if (ctx.url.pathname !== resourcePath)
|
|
156
|
+
return next();
|
|
157
|
+
const token = bearerToken(ctx.request);
|
|
158
|
+
if (token !== null) {
|
|
159
|
+
const agent = await check(token);
|
|
160
|
+
ctx.bearer = agent ? { ok: true, agent } : { ok: false, error: 'invalid_token' };
|
|
161
|
+
}
|
|
162
|
+
return next();
|
|
163
|
+
});
|
|
164
|
+
const shown = new WeakMap();
|
|
165
|
+
function pendingList(ctx) {
|
|
166
|
+
const now = Date.now();
|
|
167
|
+
const list = ctx.session.get(PENDING_KEY) ?? [];
|
|
168
|
+
return Array.isArray(list) ? list.filter((p) => isObject(p) && p.expiresAt > now) : [];
|
|
169
|
+
}
|
|
170
|
+
async function validate(ctx) {
|
|
171
|
+
const q = ctx.url.searchParams;
|
|
172
|
+
const one = (name) => (q.getAll(name).length > 1 ? null : q.get(name));
|
|
173
|
+
const clientId = one('client_id');
|
|
174
|
+
if (!clientId)
|
|
175
|
+
return { problem: 'The app did not say who it is (client_id).' };
|
|
176
|
+
let client;
|
|
177
|
+
try {
|
|
178
|
+
clientIdUrl(clientId);
|
|
179
|
+
if (!allowed(clientId))
|
|
180
|
+
return { problem: 'This app is not allowed to sign in to this site.' };
|
|
181
|
+
client = await loader.load(clientId);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
return { problem: error instanceof ClientError ? error.message : 'The app could not be checked.' };
|
|
185
|
+
}
|
|
186
|
+
const redirectUri = one('redirect_uri');
|
|
187
|
+
if (!redirectUri || !redirectAllowed(client, redirectUri))
|
|
188
|
+
return { problem: 'The app asked to send you somewhere it did not register (redirect_uri).' };
|
|
189
|
+
// From here the redirect URI is proven, but nothing redirects until the person chooses.
|
|
190
|
+
if (one('response_type') !== 'code')
|
|
191
|
+
return { problem: 'The app asked for an unsupported response_type; only "code" is supported.' };
|
|
192
|
+
const challenge = one('code_challenge');
|
|
193
|
+
if (one('code_challenge_method') !== 'S256' || !challenge || !/^[A-Za-z0-9._~-]{43,128}$/.test(challenge))
|
|
194
|
+
return { problem: 'The app must use PKCE with S256.' };
|
|
195
|
+
const askedResource = one('resource');
|
|
196
|
+
let resourceOk = false;
|
|
197
|
+
try {
|
|
198
|
+
const r = new URL(askedResource ?? '');
|
|
199
|
+
resourceOk = !r.hash && `${r.protocol}//${r.host}${r.pathname.replace(/\/$/, '')}`.toLowerCase() === resource.toLowerCase();
|
|
200
|
+
}
|
|
201
|
+
catch {
|
|
202
|
+
resourceOk = false;
|
|
203
|
+
}
|
|
204
|
+
if (!resourceOk)
|
|
205
|
+
return { problem: `The app must ask for this site's MCP endpoint as the resource (${resource}).` };
|
|
206
|
+
const scopeParam = one('scope');
|
|
207
|
+
const scopes = scopeParam === null || scopeParam.trim() === '' ? ['actions:read'] : [...new Set(scopeParam.trim().split(/ +/))];
|
|
208
|
+
if (!scopes.every((s) => SCOPES.includes(s)))
|
|
209
|
+
return { problem: 'The app asked for permissions this site does not offer (scope).' };
|
|
210
|
+
const state = one('state');
|
|
211
|
+
if (state !== null && state.length > 500)
|
|
212
|
+
return { problem: 'The app sent a state that is too long.' };
|
|
213
|
+
return {
|
|
214
|
+
id: newSecret(),
|
|
215
|
+
clientId,
|
|
216
|
+
clientName: client.name,
|
|
217
|
+
redirectUri,
|
|
218
|
+
scopes,
|
|
219
|
+
codeChallenge: challenge,
|
|
220
|
+
state,
|
|
221
|
+
resource,
|
|
222
|
+
expiresAt: Date.now() + PENDING_SECONDS * 1000,
|
|
223
|
+
userId: null,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
const consentPage = definePage({
|
|
227
|
+
path: '/oauth/authorize',
|
|
228
|
+
index: false,
|
|
229
|
+
async load(ctx) {
|
|
230
|
+
const requestId = ctx.url.searchParams.get('request');
|
|
231
|
+
if (requestId === null) {
|
|
232
|
+
const limited = await authorizeLimiter.hit(ctx.clientAddress, 'oauth-authorize');
|
|
233
|
+
if (!limited.allowed)
|
|
234
|
+
return { problem: 'Too many sign-in requests. Please wait a minute and try again.' };
|
|
235
|
+
const result = await validate(ctx);
|
|
236
|
+
if ('problem' in result)
|
|
237
|
+
return result;
|
|
238
|
+
// Stored on the server, so sign-in round trips carry a short URL and
|
|
239
|
+
// the state and challenge never appear in sign-in links.
|
|
240
|
+
ctx.session.set(PENDING_KEY, [...pendingList(ctx), result].slice(-MAX_PENDING));
|
|
241
|
+
return redirect(`/oauth/authorize?request=${encodeURIComponent(result.id)}`);
|
|
242
|
+
}
|
|
243
|
+
const list = pendingList(ctx);
|
|
244
|
+
const pending = list.find((p) => p.id === requestId);
|
|
245
|
+
if (!pending)
|
|
246
|
+
return { problem: 'This sign-in request has expired or was already used. Start again from the app.' };
|
|
247
|
+
const needsUser = requireUser(ctx);
|
|
248
|
+
if (needsUser)
|
|
249
|
+
return needsUser;
|
|
250
|
+
// A change needs a sign-in from the last day.
|
|
251
|
+
if (pending.scopes.includes('actions:write') && !signedInWithin(ctx, DAY_MS / 1000))
|
|
252
|
+
return requireRecentSignIn(ctx, DAY_MS / 1000);
|
|
253
|
+
if (pending.userId === null) {
|
|
254
|
+
pending.userId = ctx.user.id;
|
|
255
|
+
ctx.session.set(PENDING_KEY, list);
|
|
256
|
+
}
|
|
257
|
+
else if (pending.userId !== ctx.user.id) {
|
|
258
|
+
return { problem: 'This request was started by another account. Start again from the app.' };
|
|
259
|
+
}
|
|
260
|
+
const redirectUrl = new URL(pending.redirectUri);
|
|
261
|
+
shown.set(ctx, redirectUrl.origin);
|
|
262
|
+
return { pending, client: { host: new URL(pending.clientId).hostname, redirectHost: redirectUrl.host, loopback: isLoopback(redirectUrl) } };
|
|
263
|
+
},
|
|
264
|
+
head: (data) => ({
|
|
265
|
+
title: 'problem' in data ? 'Sign-in request refused' : 'Allow an app to act for you?',
|
|
266
|
+
description: 'An app asked to use this site on your behalf.',
|
|
267
|
+
}),
|
|
268
|
+
render: ({ data, ctx }) => {
|
|
269
|
+
if ('problem' in data) {
|
|
270
|
+
ctx.response.status = 400;
|
|
271
|
+
return (_jsxs("section", { children: [_jsx("h1", { children: "This sign-in request was refused" }), _jsx("p", { role: "alert", children: data.problem }), _jsx("p", { children: "Nothing was shared with the app. You can close this page." })] }));
|
|
272
|
+
}
|
|
273
|
+
const { pending, client } = data;
|
|
274
|
+
return (_jsxs("section", { children: [_jsx("h1", { children: "Allow an app to act for you?" }), _jsxs("p", { children: ["An app from ", _jsx("strong", { children: client.host }), " wants to use this site as you, ", ctx.user?.email ?? ctx.user?.name ?? ctx.user?.id, "."] }), _jsxs("p", { children: ["It calls itself \u201C", pending.clientName, "\u201D. Anyone can choose that name, so trust the address above, not the name."] }), _jsxs("p", { children: ["After you choose, you go back to ", _jsx("strong", { children: client.redirectHost }), ".", client.loopback ? ' That is an app running on this computer: only allow it if you just started signing in from it.' : null, client.redirectHost.split(':')[0] !== client.host && !client.loopback ? ' That is not the same address as the app; be sure you trust both.' : null] }), _jsx("h2", { children: "It will be able to" }), _jsx("ul", { children: pending.scopes.map((s) => (_jsx("li", { children: SCOPE_TEXT[s] }))) }), _jsxs("p", { children: ["It cannot approve anything for you, and it cannot see or change your sign-in. You can remove it at any time from ", _jsx("a", { href: connectedAppsPath, children: "your connected apps" }), "."] }), _jsxs("form", { method: "post", action: "/oauth/authorize", children: [_jsx("input", { type: "hidden", name: "request", value: pending.id }), _jsx("button", { type: "submit", name: "decision", value: "allow", children: "Allow" }), ' ', _jsx("button", { type: "submit", name: "decision", value: "deny", children: "Deny" })] })] }));
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
api.page(consentPage);
|
|
278
|
+
// --- The person's decision ---------------------------------------------------
|
|
279
|
+
api.route('POST', '/oauth/authorize', async (ctx) => {
|
|
280
|
+
const h = ctx.request.headers;
|
|
281
|
+
const refuse = (message, status = 403) => new Response(message, { status, headers: { 'content-type': 'text/plain; charset=utf-8', ...noStore } });
|
|
282
|
+
// A person pressing a button on the page, in a browser, signed in.
|
|
283
|
+
if (ctx.agent || h.has('authorization'))
|
|
284
|
+
return refuse('An app cannot consent for itself.');
|
|
285
|
+
if (h.get('sec-fetch-site') !== 'same-origin' || h.get('sec-fetch-mode') !== 'navigate' || h.get('sec-fetch-dest') !== 'document')
|
|
286
|
+
return refuse('Choose on the page, in a web browser.');
|
|
287
|
+
let form;
|
|
288
|
+
try {
|
|
289
|
+
form = new URLSearchParams(await readBodyText(ctx.request, 2048));
|
|
290
|
+
}
|
|
291
|
+
catch (error) {
|
|
292
|
+
if (error instanceof BodyError)
|
|
293
|
+
return refuse(error.message, error.status);
|
|
294
|
+
throw error;
|
|
295
|
+
}
|
|
296
|
+
if (!ctx.user)
|
|
297
|
+
return refuse('Sign in first.');
|
|
298
|
+
const list = pendingList(ctx);
|
|
299
|
+
const pending = list.find((p) => p.id === form.get('request'));
|
|
300
|
+
if (!pending || pending.userId !== ctx.user.id)
|
|
301
|
+
return refuse('This sign-in request has expired or belongs to another account. Start again from the app.', 400);
|
|
302
|
+
// Single use.
|
|
303
|
+
ctx.session.set(PENDING_KEY, list.filter((p) => p !== pending));
|
|
304
|
+
const back = new URL(pending.redirectUri);
|
|
305
|
+
if (pending.state !== null)
|
|
306
|
+
back.searchParams.set('state', pending.state);
|
|
307
|
+
back.searchParams.set('iss', issuer);
|
|
308
|
+
const decision = form.get('decision');
|
|
309
|
+
if (decision === 'allow') {
|
|
310
|
+
const now = Date.now();
|
|
311
|
+
const loopback = isLoopback(new URL(pending.redirectUri));
|
|
312
|
+
const grant = {
|
|
313
|
+
id: newSecret(),
|
|
314
|
+
userId: ctx.user.id,
|
|
315
|
+
clientId: pending.clientId,
|
|
316
|
+
clientName: pending.clientName,
|
|
317
|
+
redirectHost: new URL(pending.redirectUri).host,
|
|
318
|
+
scopes: pending.scopes,
|
|
319
|
+
createdAt: now,
|
|
320
|
+
expiresAt: now + Math.min(grantMs, loopback ? 7 * DAY_MS : grantMs),
|
|
321
|
+
lastUsedAt: null,
|
|
322
|
+
revokedAt: null,
|
|
323
|
+
};
|
|
324
|
+
const code = newSecret();
|
|
325
|
+
await store.createGrant(grant, {
|
|
326
|
+
hash: await hashSecret(code),
|
|
327
|
+
grantId: grant.id,
|
|
328
|
+
kind: 'code',
|
|
329
|
+
expiresAt: now + CODE_SECONDS * 1000,
|
|
330
|
+
usedAt: null,
|
|
331
|
+
details: { redirectUri: pending.redirectUri, codeChallenge: pending.codeChallenge, resource: pending.resource },
|
|
332
|
+
});
|
|
333
|
+
back.searchParams.set('code', code);
|
|
334
|
+
}
|
|
335
|
+
else {
|
|
336
|
+
back.searchParams.set('error', 'access_denied');
|
|
337
|
+
}
|
|
338
|
+
return new Response(null, { status: 303, headers: { location: back.href, 'referrer-policy': 'no-referrer', ...noStore } });
|
|
339
|
+
});
|
|
340
|
+
// Pages that must never be framed, and the consent page's one extra form target.
|
|
341
|
+
api.use(async (ctx, next) => {
|
|
342
|
+
const consent = ctx.route.kind === 'page' && ctx.route.page === consentPage;
|
|
343
|
+
const apps = ctx.route.kind === 'page' && ctx.route.page === appsPage;
|
|
344
|
+
if (!consent && !apps)
|
|
345
|
+
return next();
|
|
346
|
+
const response = await next();
|
|
347
|
+
const headers = new Headers(response.headers);
|
|
348
|
+
let csp = headers.get('content-security-policy') ?? "default-src 'self'; form-action 'self'";
|
|
349
|
+
csp = withDirective(csp, 'frame-ancestors', "'none'");
|
|
350
|
+
const target = shown.get(ctx);
|
|
351
|
+
// Browsers apply form-action to the redirect after the post, so the
|
|
352
|
+
// consent page alone may send its form on to this request's app.
|
|
353
|
+
if (consent && target)
|
|
354
|
+
csp = withDirective(csp, 'form-action', `'self' ${target}`);
|
|
355
|
+
headers.set('content-security-policy', csp);
|
|
356
|
+
headers.set('x-frame-options', 'DENY');
|
|
357
|
+
headers.set('referrer-policy', 'no-referrer');
|
|
358
|
+
headers.set('cache-control', 'no-store');
|
|
359
|
+
return new Response(response.body, { status: response.status, statusText: response.statusText, headers });
|
|
360
|
+
});
|
|
361
|
+
// --- Tokens ---------------------------------------------------------------------
|
|
362
|
+
async function issue(grant) {
|
|
363
|
+
const now = Date.now();
|
|
364
|
+
const access = newSecret();
|
|
365
|
+
const refresh = newSecret();
|
|
366
|
+
const secrets = [
|
|
367
|
+
{ hash: await hashSecret(access), grantId: grant.id, kind: 'access', expiresAt: Math.min(now + ACCESS_SECONDS * 1000, grant.expiresAt), usedAt: null },
|
|
368
|
+
{ hash: await hashSecret(refresh), grantId: grant.id, kind: 'refresh', expiresAt: grant.expiresAt, usedAt: null },
|
|
369
|
+
];
|
|
370
|
+
await store.issue(secrets);
|
|
371
|
+
return tokenJson({ access_token: access, token_type: 'Bearer', expires_in: ACCESS_SECONDS, refresh_token: refresh, scope: grant.scopes.join(' ') });
|
|
372
|
+
}
|
|
373
|
+
async function liveGrant(id, clientId) {
|
|
374
|
+
const now = Date.now();
|
|
375
|
+
const grant = await store.getGrant(id);
|
|
376
|
+
if (!grant || grant.revokedAt !== null || grant.expiresAt <= now || grant.clientId !== clientId)
|
|
377
|
+
return null;
|
|
378
|
+
const user = await currentUser(grant.userId);
|
|
379
|
+
if (!user) {
|
|
380
|
+
await store.revoke(grant.id, now);
|
|
381
|
+
return null;
|
|
382
|
+
}
|
|
383
|
+
return grant;
|
|
384
|
+
}
|
|
385
|
+
api.route('POST', '/oauth/token', async (ctx) => {
|
|
386
|
+
const limited = await tokenLimiter.hit(ctx.clientAddress, 'oauth-token');
|
|
387
|
+
if (!limited.allowed)
|
|
388
|
+
return oauthError('slow_down', 'Too many requests.', 429);
|
|
389
|
+
if (ctx.agent)
|
|
390
|
+
return oauthError('invalid_request', 'Not for agents.');
|
|
391
|
+
const type = (ctx.request.headers.get('content-type') ?? '').split(';')[0].trim().toLowerCase();
|
|
392
|
+
if (type !== 'application/x-www-form-urlencoded')
|
|
393
|
+
return oauthError('invalid_request', 'Send the request as application/x-www-form-urlencoded.');
|
|
394
|
+
let form;
|
|
395
|
+
try {
|
|
396
|
+
form = new URLSearchParams(await readBodyText(ctx.request, 8192));
|
|
397
|
+
}
|
|
398
|
+
catch (error) {
|
|
399
|
+
if (error instanceof BodyError)
|
|
400
|
+
return oauthError('invalid_request', error.message, error.status);
|
|
401
|
+
throw error;
|
|
402
|
+
}
|
|
403
|
+
for (const name of new Set(form.keys()))
|
|
404
|
+
if (form.getAll(name).length > 1)
|
|
405
|
+
return oauthError('invalid_request', `${name} appears more than once.`);
|
|
406
|
+
const now = Date.now();
|
|
407
|
+
const clientId = form.get('client_id');
|
|
408
|
+
const grantType = form.get('grant_type');
|
|
409
|
+
if (grantType === 'authorization_code') {
|
|
410
|
+
const code = form.get('code');
|
|
411
|
+
const verifier = form.get('code_verifier');
|
|
412
|
+
if (!code || !verifier || !/^[A-Za-z0-9._~-]{43,128}$/.test(verifier))
|
|
413
|
+
return oauthError('invalid_request', 'Send code and a code_verifier of 43 to 128 characters.');
|
|
414
|
+
const used = await store.use(await hashSecret(code), 'code', now);
|
|
415
|
+
if (!used.ok) {
|
|
416
|
+
// A code used twice was copied: everything issued from it goes.
|
|
417
|
+
if (used.reason === 'reused')
|
|
418
|
+
await store.revoke(used.grantId, now);
|
|
419
|
+
return oauthError('invalid_grant', 'The code is not valid.');
|
|
420
|
+
}
|
|
421
|
+
const details = used.secret.details;
|
|
422
|
+
const grant = await liveGrant(used.secret.grantId, clientId);
|
|
423
|
+
const resourceOk = form.get('resource') === null || form.get('resource') === details?.resource;
|
|
424
|
+
if (!grant || !details || form.get('redirect_uri') !== details.redirectUri || !resourceOk || !same(await s256(verifier), details.codeChallenge)) {
|
|
425
|
+
// The code is spent either way; a grant with no tokens is no use to anyone.
|
|
426
|
+
await store.revoke(used.secret.grantId, now);
|
|
427
|
+
return oauthError('invalid_grant', 'The code, client, redirect_uri, resource or code_verifier do not match.');
|
|
428
|
+
}
|
|
429
|
+
return issue(grant);
|
|
430
|
+
}
|
|
431
|
+
if (grantType === 'refresh_token') {
|
|
432
|
+
const refresh = form.get('refresh_token');
|
|
433
|
+
if (!refresh)
|
|
434
|
+
return oauthError('invalid_request', 'Send refresh_token.');
|
|
435
|
+
const used = await store.use(await hashSecret(refresh), 'refresh', now);
|
|
436
|
+
if (!used.ok) {
|
|
437
|
+
// Rotation: an old refresh token used again means it was copied.
|
|
438
|
+
if (used.reason === 'reused')
|
|
439
|
+
await store.revoke(used.grantId, now);
|
|
440
|
+
return oauthError('invalid_grant', 'The refresh token is not valid.');
|
|
441
|
+
}
|
|
442
|
+
const grant = await liveGrant(used.secret.grantId, clientId);
|
|
443
|
+
if (!grant)
|
|
444
|
+
return oauthError('invalid_grant', 'The grant has ended or belongs to another client.');
|
|
445
|
+
const scope = form.get('scope');
|
|
446
|
+
if (scope !== null && scope.trim() !== '' && [...new Set(scope.trim().split(/ +/))].sort().join(' ') !== [...grant.scopes].sort().join(' ')) {
|
|
447
|
+
return oauthError('invalid_scope', 'Refreshing keeps the scopes the person granted; ask the person again to change them.');
|
|
448
|
+
}
|
|
449
|
+
const askedResource = form.get('resource');
|
|
450
|
+
if (askedResource !== null && askedResource !== resource)
|
|
451
|
+
return oauthError('invalid_target', 'The resource is not this site’s MCP endpoint.');
|
|
452
|
+
return issue(grant);
|
|
453
|
+
}
|
|
454
|
+
return oauthError('unsupported_grant_type', 'Use authorization_code or refresh_token.');
|
|
455
|
+
});
|
|
456
|
+
api.route('POST', '/oauth/revoke', async (ctx) => {
|
|
457
|
+
const limited = await tokenLimiter.hit(ctx.clientAddress, 'oauth-revoke');
|
|
458
|
+
if (!limited.allowed)
|
|
459
|
+
return oauthError('slow_down', 'Too many requests.', 429);
|
|
460
|
+
let form;
|
|
461
|
+
try {
|
|
462
|
+
form = new URLSearchParams(await readBodyText(ctx.request, 8192));
|
|
463
|
+
}
|
|
464
|
+
catch (error) {
|
|
465
|
+
if (error instanceof BodyError)
|
|
466
|
+
return oauthError('invalid_request', error.message, error.status);
|
|
467
|
+
throw error;
|
|
468
|
+
}
|
|
469
|
+
const token = form.get('token');
|
|
470
|
+
if (token) {
|
|
471
|
+
const found = await store.lookup(await hashSecret(token));
|
|
472
|
+
const grant = found && found.kind !== 'code' ? await store.getGrant(found.grantId) : undefined;
|
|
473
|
+
// Only the client that holds the grant can revoke it this way.
|
|
474
|
+
if (grant && grant.clientId === form.get('client_id'))
|
|
475
|
+
await store.revoke(grant.id, Date.now());
|
|
476
|
+
}
|
|
477
|
+
// Always 200 (RFC 7009), so the answer says nothing about the token.
|
|
478
|
+
return new Response(null, { status: 200, headers: noStore });
|
|
479
|
+
});
|
|
480
|
+
// --- Connected apps ---------------------------------------------------------------
|
|
481
|
+
const revokeApp = defineAction({
|
|
482
|
+
name: 'revoke_connected_app',
|
|
483
|
+
title: 'Remove',
|
|
484
|
+
description: 'Removes an app the signed-in person allowed to act for them.',
|
|
485
|
+
risk: 'write',
|
|
486
|
+
agents: false,
|
|
487
|
+
permission: (ctx) => Boolean(ctx.user) && !ctx.agent,
|
|
488
|
+
input: { grant: field.text({ label: 'App', max: 64 }) },
|
|
489
|
+
async run({ grant: id }, ctx) {
|
|
490
|
+
const grant = await store.getGrant(id);
|
|
491
|
+
// Another person's grant is answered like one that does not exist.
|
|
492
|
+
if (grant && grant.userId === ctx.user?.id)
|
|
493
|
+
await store.revoke(grant.id, Date.now());
|
|
494
|
+
return { message: 'The app was removed. It can no longer act for you.' };
|
|
495
|
+
},
|
|
496
|
+
});
|
|
497
|
+
api.action(revokeApp);
|
|
498
|
+
const appsPage = definePage({
|
|
499
|
+
path: connectedAppsPath,
|
|
500
|
+
index: false,
|
|
501
|
+
async load(ctx) {
|
|
502
|
+
const needsUser = requireUser(ctx);
|
|
503
|
+
if (needsUser)
|
|
504
|
+
return needsUser;
|
|
505
|
+
return { grants: await store.grantsOf(ctx.user.id, Date.now()), activity: api.hasPlugin('approvals') };
|
|
506
|
+
},
|
|
507
|
+
head: { title: 'Connected apps', description: 'Apps you allowed to act for you on this site.' },
|
|
508
|
+
render: ({ data: { grants, activity } }) => (_jsxs("section", { children: [_jsx("h1", { children: "Connected apps" }), activity ? (_jsxs("p", { children: ["See ", _jsx("a", { href: "/pexis/approvals/activity", children: "what your apps did" }), ", and reverse changes."] })) : null, grants.length === 0 ? (_jsx("p", { children: "No apps can act for you." })) : (_jsx("ul", { children: grants.map((g) => (_jsxs("li", { children: [_jsx("strong", { children: new URL(g.clientId).hostname }), " (calls itself \u201C", g.clientName, "\u201D), returning to ", g.redirectHost, ". Can ", g.scopes.includes('actions:write') ? 'look things up and make changes' : 'look things up', ". Allowed", ' ', _jsx("time", { datetime: new Date(g.createdAt).toISOString(), children: new Date(g.createdAt).toISOString().slice(0, 10) }), g.lastUsedAt ? `, last used ${new Date(g.lastUsedAt).toISOString().slice(0, 10)}` : ', not used yet', ".", _jsxs("form", { method: "post", action: "/actions/revoke_connected_app", children: [_jsx("input", { type: "hidden", name: "grant", value: g.id }), _jsxs("button", { type: "submit", children: ["Remove ", new URL(g.clientId).hostname] })] })] }))) })), _jsx("p", { children: "Signing out does not remove these apps. Remove an app here to stop it at once." })] })),
|
|
509
|
+
});
|
|
510
|
+
api.page(appsPage);
|
|
511
|
+
api.adminPanel({
|
|
512
|
+
path: 'connected-apps',
|
|
513
|
+
title: 'Connected apps',
|
|
514
|
+
async render() {
|
|
515
|
+
const grants = await store.recent(100, Date.now());
|
|
516
|
+
return (_jsxs(_Fragment, { children: [_jsxs("p", { children: ["Apps people allowed to act for them (newest first). Read-only: people remove their own apps on ", connectedAppsPath, "."] }), _jsxs("table", { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: "col", children: "App" }), _jsx("th", { scope: "col", children: "Person" }), _jsx("th", { scope: "col", children: "Can" }), _jsx("th", { scope: "col", children: "Allowed" }), _jsx("th", { scope: "col", children: "Last used" })] }) }), _jsx("tbody", { children: grants.map((g) => (_jsxs("tr", { children: [_jsx("td", { children: new URL(g.clientId).hostname }), _jsx("td", { children: g.userId }), _jsx("td", { children: g.scopes.join(', ') }), _jsx("td", { children: new Date(g.createdAt).toISOString() }), _jsx("td", { children: g.lastUsedAt ? new Date(g.lastUsedAt).toISOString() : 'never' })] }))) })] })] }));
|
|
517
|
+
},
|
|
518
|
+
});
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
//# sourceMappingURL=plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../src/server/plugin.tsx"],"names":[],"mappings":";AAAA,4EAA4E;AAC5E,wEAAwE;AACxE,2EAA2E;AAC3E,EAAE;AACF,8BAA8B;AAC9B,4EAA4E;AAC5E,2EAA2E;AAC3E,uCAAuC;AACvC,4CAA4C;AAC5C,2EAA2E;AAC3E,qCAAqC;AACrC,qEAAqE;AAErE,OAAO,EACL,SAAS,EACT,YAAY,EACZ,UAAU,EACV,YAAY,EACZ,KAAK,EACL,WAAW,EACX,YAAY,EACZ,QAAQ,GAKT,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,cAAc,EAAa,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,YAAY,EAAE,UAAU,EAAE,eAAe,EAAE,gBAAgB,EAA2C,MAAM,aAAa,CAAC;AAC7J,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,SAAS,EAAuD,MAAM,YAAY,CAAC;AAE1H,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,cAAc,EAAE,eAAe,CAAU,CAAC;AACjE,MAAM,UAAU,GAA2B;IACzC,cAAc,EAAE,sFAAsF;IACtG,eAAe,EAAE,yGAAyG;CAC3H,CAAC;AACF,MAAM,cAAc,GAAG,EAAE,GAAG,EAAE,CAAC;AAC/B,MAAM,YAAY,GAAG,EAAE,CAAC;AACxB,MAAM,eAAe,GAAG,EAAE,GAAG,EAAE,CAAC;AAChC,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,WAAW,GAAG,qBAAqB,CAA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