Remove OAuth authorization flows and use API key authentication for MCP
This commit is contained in:
1 parent
16acac5530
commit
b185837063
85 files changed
+383
-4631
No files matched your search
@@ -10,9 +10,10 @@ const operation1 = defineOperation({
|
||||
auth: 'bearer',
|
||||
operation: {
|
||||
operationId: 'getMe',
|
||||
summary: 'Get me',
|
||||
summary: 'Get my authentication details',
|
||||
description:
|
||||
'Returns the current authentication context, including the authenticated user or share credentials.',
|
||||
tags: ['Account'],
|
||||
'x-umami-oauth-scope': 'websites:read',
|
||||
responses: {
|
||||
'200': {
|
||||
description: 'The operation completed successfully.',
|
||||
@@ -26,30 +27,38 @@ const operation1 = defineOperation({
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
description: 'Username of the account.',
|
||||
},
|
||||
role: {
|
||||
type: 'string',
|
||||
description: 'Permission role assigned to the user.',
|
||||
},
|
||||
isAdmin: {
|
||||
type: 'boolean',
|
||||
description: 'Whether the user has administrator privileges.',
|
||||
},
|
||||
},
|
||||
required: ['id', 'username', 'role', 'isAdmin'],
|
||||
description: 'User associated with the resource.',
|
||||
},
|
||||
apiKey: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
description: 'Display name of the resource.',
|
||||
},
|
||||
},
|
||||
required: ['id', 'name'],
|
||||
description: 'API key authentication details.',
|
||||
},
|
||||
authType: {
|
||||
anyOf: [
|
||||
@@ -62,37 +71,18 @@ const operation1 = defineOperation({
|
||||
{
|
||||
const: 'api-key',
|
||||
},
|
||||
{
|
||||
const: 'oauth',
|
||||
},
|
||||
],
|
||||
},
|
||||
oauth: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
clientId: {
|
||||
type: 'string',
|
||||
},
|
||||
scopes: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
tokenId: {
|
||||
type: 'string',
|
||||
},
|
||||
},
|
||||
required: ['clientId', 'scopes'],
|
||||
},
|
||||
shareToken: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
shareType: {
|
||||
type: 'number',
|
||||
description: 'Type of resource made available by the share.',
|
||||
},
|
||||
websiteId: {
|
||||
type: 'string',
|
||||
description: 'ID of the website.',
|
||||
},
|
||||
websiteIds: {
|
||||
type: 'array',
|
||||
@@ -102,9 +92,11 @@ const operation1 = defineOperation({
|
||||
},
|
||||
boardId: {
|
||||
type: 'string',
|
||||
description: 'ID of the board.',
|
||||
},
|
||||
pixelId: {
|
||||
type: 'string',
|
||||
description: 'ID of the tracking pixel.',
|
||||
},
|
||||
pixelIds: {
|
||||
type: 'array',
|
||||
@@ -114,6 +106,7 @@ const operation1 = defineOperation({
|
||||
},
|
||||
linkId: {
|
||||
type: 'string',
|
||||
description: 'ID of the tracked link.',
|
||||
},
|
||||
linkIds: {
|
||||
type: 'array',
|
||||
@@ -154,6 +147,7 @@ const operation1 = defineOperation({
|
||||
},
|
||||
],
|
||||
},
|
||||
description: 'Configuration parameters for the resource.',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,54 +0,0 @@
|
||||
import { defineOperation } from '@/openapi/operation';
|
||||
import { badRequestResponse, jsonResponse, unauthorizedResponse } from '@/openapi/schemas';
|
||||
import {
|
||||
authorizationDecisionSchema,
|
||||
authorizationDetailsSchema,
|
||||
authorizationRedirectSchema,
|
||||
authorizationRequestSchema,
|
||||
oauthErrorSchema,
|
||||
} from '../schema';
|
||||
|
||||
const describeAuthorizationOperation = defineOperation({
|
||||
method: 'get',
|
||||
path: '/api/oauth/authorize',
|
||||
audience: 'internal',
|
||||
auth: 'bearer',
|
||||
operation: {
|
||||
operationId: 'describeOAuthAuthorization',
|
||||
summary: 'Describe a pending OAuth authorization request',
|
||||
description:
|
||||
'Validates an OAuth 2.1 authorization request and returns the client and scopes for the consent screen. Requires an interactive user session.',
|
||||
tags: ['OAuth'],
|
||||
requestParams: { query: authorizationRequestSchema },
|
||||
responses: {
|
||||
'200': jsonResponse(authorizationDetailsSchema, 'Authorization request details.'),
|
||||
'400': jsonResponse(oauthErrorSchema, 'Invalid authorization request.'),
|
||||
'401': unauthorizedResponse,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
const decideAuthorizationOperation = defineOperation({
|
||||
method: 'post',
|
||||
path: '/api/oauth/authorize',
|
||||
audience: 'internal',
|
||||
auth: 'bearer',
|
||||
operation: {
|
||||
operationId: 'decideOAuthAuthorization',
|
||||
summary: 'Approve or deny an OAuth authorization request',
|
||||
description:
|
||||
'Records the user decision. On approval an authorization code is issued and the redirect URL (with code, state and iss) is returned.',
|
||||
tags: ['OAuth'],
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: { 'application/json': { schema: authorizationDecisionSchema } },
|
||||
},
|
||||
responses: {
|
||||
'200': jsonResponse(authorizationRedirectSchema, 'Redirect URL for the browser.'),
|
||||
'400': badRequestResponse,
|
||||
'401': unauthorizedResponse,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const operations = [describeAuthorizationOperation, decideAuthorizationOperation] as const;
|
||||
@@ -1,100 +0,0 @@
|
||||
import {
|
||||
buildErrorRedirect,
|
||||
buildSuccessRedirect,
|
||||
issueAuthorizationCode,
|
||||
validateAuthorizationRequest,
|
||||
} from '@/lib/oauth/authorize';
|
||||
import { getIssuer, isOAuthEnabled } from '@/lib/oauth/config';
|
||||
import { OAuthError, oauthErrorResponse } from '@/lib/oauth/errors';
|
||||
import { OAUTH_SCOPE_DESCRIPTIONS } from '@/lib/oauth/scopes';
|
||||
import { parseRequest } from '@/lib/request';
|
||||
import { json, notFound, unauthorized } from '@/lib/response';
|
||||
import { authorizationDecisionSchema, authorizationRequestSchema } from '../schema';
|
||||
|
||||
function requireSession(auth: { user?: { id: string }; authType?: string } | null) {
|
||||
// Only an interactive user session may grant consent: never an API key or another OAuth token.
|
||||
return !!auth?.user?.id && (auth.authType === undefined || auth.authType === 'session');
|
||||
}
|
||||
|
||||
/**
|
||||
* Describes a pending authorization request for the consent screen. Validation errors are
|
||||
* returned as JSON (the consent UI renders them) — no redirect happens until the user decides.
|
||||
*/
|
||||
export async function GET(request: Request) {
|
||||
if (!isOAuthEnabled()) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
const { auth, query, error } = await parseRequest(request, authorizationRequestSchema);
|
||||
|
||||
if (error) {
|
||||
return error();
|
||||
}
|
||||
|
||||
if (!requireSession(auth)) {
|
||||
return unauthorized();
|
||||
}
|
||||
|
||||
try {
|
||||
const validated = await validateAuthorizationRequest(query, getIssuer(request.headers));
|
||||
|
||||
return json({
|
||||
client: {
|
||||
id: validated.client.clientId,
|
||||
name: validated.client.clientName,
|
||||
uri: validated.client.clientUri,
|
||||
logoUri: validated.client.logoUri,
|
||||
source: validated.client.source,
|
||||
},
|
||||
scopes: validated.scopes.map(scope => ({
|
||||
scope,
|
||||
description: OAUTH_SCOPE_DESCRIPTIONS[scope],
|
||||
})),
|
||||
redirectUri: validated.redirectUri,
|
||||
resource: validated.resource,
|
||||
});
|
||||
} catch (err) {
|
||||
return oauthErrorResponse(err);
|
||||
}
|
||||
}
|
||||
|
||||
/** Records the user's decision and returns the redirect URL the browser should navigate to. */
|
||||
export async function POST(request: Request) {
|
||||
if (!isOAuthEnabled()) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
const { auth, body, error } = await parseRequest(request, authorizationDecisionSchema);
|
||||
|
||||
if (error) {
|
||||
return error();
|
||||
}
|
||||
|
||||
if (!requireSession(auth)) {
|
||||
return unauthorized();
|
||||
}
|
||||
|
||||
const issuer = getIssuer(request.headers);
|
||||
const { decision, ...params } = body;
|
||||
|
||||
try {
|
||||
const validated = await validateAuthorizationRequest(params, issuer);
|
||||
|
||||
if (decision !== 'approve') {
|
||||
return json({
|
||||
redirectUrl: buildErrorRedirect(
|
||||
validated.redirectUri,
|
||||
new OAuthError('access_denied', 'The user denied the request.'),
|
||||
validated.state,
|
||||
issuer,
|
||||
),
|
||||
});
|
||||
}
|
||||
|
||||
const code = await issueAuthorizationCode(validated, auth.user.id);
|
||||
|
||||
return json({ redirectUrl: buildSuccessRedirect(validated, code, issuer) });
|
||||
} catch (err) {
|
||||
return oauthErrorResponse(err);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
import { defineOperation } from '@/openapi/operation';
|
||||
import { jsonResponse } from '@/openapi/schemas';
|
||||
import {
|
||||
clientRegistrationRequestSchema,
|
||||
clientRegistrationResponseSchema,
|
||||
oauthErrorSchema,
|
||||
} from '../schema';
|
||||
|
||||
const registerOperation = defineOperation({
|
||||
method: 'post',
|
||||
path: '/api/oauth/register',
|
||||
audience: 'internal',
|
||||
auth: 'none',
|
||||
operation: {
|
||||
operationId: 'oauthRegisterClient',
|
||||
summary: 'Register an OAuth client (dynamic client registration)',
|
||||
description:
|
||||
'RFC 7591 compatibility endpoint for MCP clients without Client ID Metadata Document support. Registers a public client. Prefer Client ID Metadata Documents (https URL client_id).',
|
||||
tags: ['OAuth'],
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: { 'application/json': { schema: clientRegistrationRequestSchema } },
|
||||
},
|
||||
responses: {
|
||||
'201': jsonResponse(clientRegistrationResponseSchema, 'Registered client.'),
|
||||
'400': jsonResponse(oauthErrorSchema, 'Invalid client metadata.'),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const operations = [registerOperation] as const;
|
||||
@@ -1,90 +0,0 @@
|
||||
import { uuid } from '@/lib/crypto';
|
||||
import { isDynamicRegistrationEnabled } from '@/lib/oauth/config';
|
||||
import { OAuthError, oauthErrorResponse, oauthJson } from '@/lib/oauth/errors';
|
||||
import { corsPreflight } from '@/lib/oauth/metadata';
|
||||
import { isAcceptableRedirectUri } from '@/lib/oauth/redirect';
|
||||
import { parseRequest } from '@/lib/request';
|
||||
import { notFound } from '@/lib/response';
|
||||
import { createOauthClient } from '@/queries/prisma/oauth';
|
||||
import { clientRegistrationRequestSchema } from '../schema';
|
||||
|
||||
export function OPTIONS() {
|
||||
return corsPreflight();
|
||||
}
|
||||
|
||||
/**
|
||||
* Dynamic Client Registration (RFC 7591) compatibility endpoint for MCP clients that do not yet
|
||||
* support Client ID Metadata Documents. Public clients only; disable with OAUTH_DISABLE_DCR=1.
|
||||
*/
|
||||
export async function POST(request: Request) {
|
||||
if (!isDynamicRegistrationEnabled()) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
const { body, error } = await parseRequest(request, clientRegistrationRequestSchema, {
|
||||
skipAuth: true,
|
||||
});
|
||||
|
||||
if (error) {
|
||||
return oauthJson(
|
||||
{ error: 'invalid_client_metadata', error_description: 'Invalid registration request.' },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
if (!body.redirect_uris.every(isAcceptableRedirectUri)) {
|
||||
throw new OAuthError(
|
||||
'invalid_redirect_uri',
|
||||
'redirect_uris must be absolute https, loopback http or custom-scheme URLs without fragments.',
|
||||
);
|
||||
}
|
||||
|
||||
const grantTypes = body.grant_types ?? ['authorization_code', 'refresh_token'];
|
||||
const responseTypes = body.response_types ?? ['code'];
|
||||
|
||||
if (grantTypes.some(type => !['authorization_code', 'refresh_token'].includes(type))) {
|
||||
throw new OAuthError('invalid_client_metadata', 'Unsupported grant_types.');
|
||||
}
|
||||
|
||||
if (responseTypes.some(type => type !== 'code')) {
|
||||
throw new OAuthError('invalid_client_metadata', 'Unsupported response_types.');
|
||||
}
|
||||
|
||||
const id = uuid();
|
||||
const metadata = {
|
||||
client_uri: body.client_uri,
|
||||
logo_uri: body.logo_uri,
|
||||
application_type: body.application_type,
|
||||
software_id: body.software_id,
|
||||
software_version: body.software_version,
|
||||
scope: body.scope,
|
||||
};
|
||||
|
||||
const client = await createOauthClient({
|
||||
id,
|
||||
name: body.client_name,
|
||||
redirectUris: body.redirect_uris,
|
||||
metadata,
|
||||
});
|
||||
|
||||
return oauthJson(
|
||||
{
|
||||
client_id: client.id,
|
||||
client_id_issued_at: Math.floor((client.createdAt ?? new Date()).getTime() / 1000),
|
||||
client_name: client.name,
|
||||
redirect_uris: body.redirect_uris,
|
||||
token_endpoint_auth_method: 'none',
|
||||
grant_types: grantTypes,
|
||||
response_types: responseTypes,
|
||||
...(body.client_uri ? { client_uri: body.client_uri } : {}),
|
||||
...(body.logo_uri ? { logo_uri: body.logo_uri } : {}),
|
||||
...(body.application_type ? { application_type: body.application_type } : {}),
|
||||
...(body.scope ? { scope: body.scope } : {}),
|
||||
},
|
||||
{ status: 201 },
|
||||
);
|
||||
} catch (err) {
|
||||
return oauthErrorResponse(err);
|
||||
}
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
import { z } from 'zod';
|
||||
import { defineOperation } from '@/openapi/operation';
|
||||
import { jsonResponse } from '@/openapi/schemas';
|
||||
import { oauthErrorSchema, revocationRequestSchema } from '../schema';
|
||||
|
||||
const revokeOperation = defineOperation({
|
||||
method: 'post',
|
||||
path: '/api/oauth/revoke',
|
||||
audience: 'internal',
|
||||
auth: 'none',
|
||||
operation: {
|
||||
operationId: 'oauthRevoke',
|
||||
summary: 'Revoke an OAuth refresh token',
|
||||
description:
|
||||
'RFC 7009 revocation endpoint. Revokes the given refresh token; unknown tokens are accepted silently.',
|
||||
tags: ['OAuth'],
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
'application/x-www-form-urlencoded': { schema: revocationRequestSchema },
|
||||
'application/json': { schema: revocationRequestSchema },
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
'200': jsonResponse(z.object({}), 'Token revoked (or already invalid).'),
|
||||
'400': jsonResponse(oauthErrorSchema, 'Malformed request.'),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const operations = [revokeOperation] as const;
|
||||
@@ -1,34 +0,0 @@
|
||||
import { isOAuthEnabled } from '@/lib/oauth/config';
|
||||
import { oauthErrorResponse, oauthJson } from '@/lib/oauth/errors';
|
||||
import { readOAuthBody } from '@/lib/oauth/form';
|
||||
import { corsPreflight } from '@/lib/oauth/metadata';
|
||||
import { handleRevocationRequest } from '@/lib/oauth/token';
|
||||
import { notFound } from '@/lib/response';
|
||||
|
||||
export function OPTIONS() {
|
||||
return corsPreflight();
|
||||
}
|
||||
|
||||
/** RFC 7009 token revocation. Always returns 200 for well-formed requests. */
|
||||
export async function POST(request: Request) {
|
||||
if (!isOAuthEnabled()) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
try {
|
||||
const params = await readOAuthBody(request);
|
||||
|
||||
if (typeof params.token !== 'string' || !params.token) {
|
||||
return oauthJson(
|
||||
{ error: 'invalid_request', error_description: 'token is required.' },
|
||||
{ status: 400 },
|
||||
);
|
||||
}
|
||||
|
||||
await handleRevocationRequest(params);
|
||||
|
||||
return oauthJson({});
|
||||
} catch (error) {
|
||||
return oauthErrorResponse(error);
|
||||
}
|
||||
}
|
||||
@@ -1,102 +0,0 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const authorizationRequestSchema = z
|
||||
.object({
|
||||
response_type: z.string().optional(),
|
||||
client_id: z.string().max(2048),
|
||||
redirect_uri: z.string().max(2048).optional(),
|
||||
scope: z.string().max(500).optional(),
|
||||
state: z.string().max(1024).optional(),
|
||||
code_challenge: z.string().max(128).optional(),
|
||||
code_challenge_method: z.string().max(10).optional(),
|
||||
resource: z.string().max(2048).optional(),
|
||||
})
|
||||
.meta({ id: 'OAuthAuthorizationRequest' });
|
||||
|
||||
export const authorizationDecisionSchema = authorizationRequestSchema
|
||||
.extend({
|
||||
decision: z.enum(['approve', 'deny']),
|
||||
})
|
||||
.meta({ id: 'OAuthAuthorizationDecision' });
|
||||
|
||||
export const authorizationDetailsSchema = z
|
||||
.object({
|
||||
client: z.object({
|
||||
id: z.string(),
|
||||
name: z.string(),
|
||||
uri: z.string().optional(),
|
||||
logoUri: z.string().optional(),
|
||||
source: z.enum(['metadata-document', 'registered']),
|
||||
}),
|
||||
scopes: z.array(z.object({ scope: z.string(), description: z.string() })),
|
||||
redirectUri: z.string(),
|
||||
resource: z.string(),
|
||||
})
|
||||
.meta({ id: 'OAuthAuthorizationDetails' });
|
||||
|
||||
export const authorizationRedirectSchema = z
|
||||
.object({ redirectUrl: z.string() })
|
||||
.meta({ id: 'OAuthAuthorizationRedirect' });
|
||||
|
||||
export const tokenRequestSchema = z
|
||||
.object({
|
||||
grant_type: z.enum(['authorization_code', 'refresh_token']),
|
||||
code: z.string().optional(),
|
||||
redirect_uri: z.string().optional(),
|
||||
client_id: z.string().optional(),
|
||||
code_verifier: z.string().optional(),
|
||||
refresh_token: z.string().optional(),
|
||||
scope: z.string().optional(),
|
||||
resource: z.string().optional(),
|
||||
})
|
||||
.meta({ id: 'OAuthTokenRequest' });
|
||||
|
||||
export const tokenResponseSchema = z
|
||||
.object({
|
||||
access_token: z.string(),
|
||||
token_type: z.literal('Bearer'),
|
||||
expires_in: z.number().int(),
|
||||
refresh_token: z.string(),
|
||||
scope: z.string(),
|
||||
})
|
||||
.meta({ id: 'OAuthTokenResponse' });
|
||||
|
||||
export const oauthErrorSchema = z
|
||||
.object({
|
||||
error: z.string(),
|
||||
error_description: z.string().optional(),
|
||||
})
|
||||
.meta({ id: 'OAuthErrorResponse' });
|
||||
|
||||
export const revocationRequestSchema = z
|
||||
.object({
|
||||
token: z.string(),
|
||||
token_type_hint: z.string().optional(),
|
||||
})
|
||||
.meta({ id: 'OAuthRevocationRequest' });
|
||||
|
||||
export const clientRegistrationRequestSchema = z
|
||||
.object({
|
||||
redirect_uris: z.array(z.string().max(2048)).min(1).max(20),
|
||||
client_name: z.string().trim().min(1).max(255),
|
||||
client_uri: z.string().max(2048).optional(),
|
||||
logo_uri: z.string().max(2048).optional(),
|
||||
token_endpoint_auth_method: z.literal('none').optional(),
|
||||
grant_types: z.array(z.string()).optional(),
|
||||
response_types: z.array(z.string()).optional(),
|
||||
application_type: z.enum(['web', 'native']).optional(),
|
||||
scope: z.string().max(500).optional(),
|
||||
software_id: z.string().max(255).optional(),
|
||||
software_version: z.string().max(255).optional(),
|
||||
})
|
||||
.meta({ id: 'OAuthClientRegistrationRequest' });
|
||||
|
||||
export const clientRegistrationResponseSchema = clientRegistrationRequestSchema
|
||||
.extend({
|
||||
client_id: z.string(),
|
||||
client_id_issued_at: z.number().int(),
|
||||
token_endpoint_auth_method: z.literal('none'),
|
||||
grant_types: z.array(z.string()),
|
||||
response_types: z.array(z.string()),
|
||||
})
|
||||
.meta({ id: 'OAuthClientRegistrationResponse' });
|
||||
@@ -1,31 +0,0 @@
|
||||
import { defineOperation } from '@/openapi/operation';
|
||||
import { jsonResponse } from '@/openapi/schemas';
|
||||
import { oauthErrorSchema, tokenRequestSchema, tokenResponseSchema } from '../schema';
|
||||
|
||||
const tokenOperation = defineOperation({
|
||||
method: 'post',
|
||||
path: '/api/oauth/token',
|
||||
audience: 'internal',
|
||||
auth: 'none',
|
||||
operation: {
|
||||
operationId: 'oauthToken',
|
||||
summary: 'OAuth 2.1 token endpoint',
|
||||
description:
|
||||
'Exchanges an authorization code (with PKCE code_verifier) or a refresh token for an access token. Accepts application/x-www-form-urlencoded or JSON. Refresh tokens are rotated on every use.',
|
||||
tags: ['OAuth'],
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
'application/x-www-form-urlencoded': { schema: tokenRequestSchema },
|
||||
'application/json': { schema: tokenRequestSchema },
|
||||
},
|
||||
},
|
||||
responses: {
|
||||
'200': jsonResponse(tokenResponseSchema, 'Access and refresh tokens.'),
|
||||
'400': jsonResponse(oauthErrorSchema, 'Invalid grant or request.'),
|
||||
'401': jsonResponse(oauthErrorSchema, 'Invalid client.'),
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
export const operations = [tokenOperation] as const;
|
||||
@@ -1,26 +0,0 @@
|
||||
import { getIssuer, isOAuthEnabled } from '@/lib/oauth/config';
|
||||
import { oauthErrorResponse, oauthJson } from '@/lib/oauth/errors';
|
||||
import { readOAuthBody } from '@/lib/oauth/form';
|
||||
import { corsPreflight } from '@/lib/oauth/metadata';
|
||||
import { handleTokenRequest } from '@/lib/oauth/token';
|
||||
import { notFound } from '@/lib/response';
|
||||
|
||||
export function OPTIONS() {
|
||||
return corsPreflight();
|
||||
}
|
||||
|
||||
/** OAuth 2.1 token endpoint: authorization_code (PKCE) and refresh_token grants. */
|
||||
export async function POST(request: Request) {
|
||||
if (!isOAuthEnabled()) {
|
||||
return notFound();
|
||||
}
|
||||
|
||||
try {
|
||||
const params = await readOAuthBody(request);
|
||||
const tokens = await handleTokenRequest(params, getIssuer(request.headers));
|
||||
|
||||
return oauthJson(tokens);
|
||||
} catch (error) {
|
||||
return oauthErrorResponse(error);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'getRealtime',
|
||||
summary: 'Get realtime website id',
|
||||
tags: ['Realtime'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
parameters: [
|
||||
{
|
||||
name: 'websiteId',
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'runAttributionReport',
|
||||
summary: 'Create or update reports attribution',
|
||||
tags: ['Reports'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'runBreakdownReport',
|
||||
summary: 'Create or update reports breakdown',
|
||||
tags: ['Reports'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'runFunnelReport',
|
||||
summary: 'Create or update reports funnel',
|
||||
tags: ['Reports'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'runJourneyReport',
|
||||
summary: 'Create or update reports journey',
|
||||
tags: ['Reports'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'runRetentionReport',
|
||||
summary: 'Create or update reports retention',
|
||||
tags: ['Reports'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'runRevenueReport',
|
||||
summary: 'Create or update reports revenue',
|
||||
tags: ['Reports'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'runUtmReport',
|
||||
summary: 'Create or update reports utm',
|
||||
tags: ['Reports'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
requestBody: {
|
||||
required: true,
|
||||
content: {
|
||||
|
||||
@@ -10,7 +10,9 @@ const operation1 = defineOperation({
|
||||
auth: 'bearer',
|
||||
operation: {
|
||||
operationId: 'deleteUser',
|
||||
summary: 'Delete users user id',
|
||||
summary: 'Delete a user',
|
||||
description:
|
||||
'Deletes the specified user account. The current user cannot delete their own account through this operation.',
|
||||
tags: ['Users'],
|
||||
parameters: [
|
||||
{
|
||||
@@ -20,6 +22,7 @@ const operation1 = defineOperation({
|
||||
schema: {
|
||||
type: 'string',
|
||||
},
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
],
|
||||
responses: {
|
||||
@@ -32,6 +35,7 @@ const operation1 = defineOperation({
|
||||
properties: {
|
||||
ok: {
|
||||
const: true,
|
||||
description: 'Whether the operation succeeded.',
|
||||
},
|
||||
},
|
||||
required: ['ok'],
|
||||
@@ -84,7 +88,9 @@ const operation2 = defineOperation({
|
||||
auth: 'bearer-or-share',
|
||||
operation: {
|
||||
operationId: 'getUser',
|
||||
summary: 'Get users user id',
|
||||
summary: 'Get a user',
|
||||
description:
|
||||
'Returns details for the specified user account when the caller has permission to view it.',
|
||||
tags: ['Users'],
|
||||
parameters: [
|
||||
{
|
||||
@@ -94,6 +100,7 @@ const operation2 = defineOperation({
|
||||
schema: {
|
||||
type: 'string',
|
||||
},
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
],
|
||||
responses: {
|
||||
@@ -109,12 +116,15 @@ const operation2 = defineOperation({
|
||||
properties: {
|
||||
isEnabled: {
|
||||
type: 'boolean',
|
||||
description: 'Whether two-factor authentication is enabled.',
|
||||
},
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
secret: {
|
||||
type: 'string',
|
||||
@@ -122,10 +132,12 @@ const operation2 = defineOperation({
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was created.',
|
||||
},
|
||||
updatedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was last updated.',
|
||||
},
|
||||
},
|
||||
required: ['isEnabled', 'id', 'userId', 'secret', 'createdAt', 'updatedAt'],
|
||||
@@ -135,13 +147,16 @@ const operation2 = defineOperation({
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
updatedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was last updated.',
|
||||
},
|
||||
attempts: {
|
||||
type: 'number',
|
||||
@@ -149,28 +164,35 @@ const operation2 = defineOperation({
|
||||
lockedUntil: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Time until which further authentication attempts are blocked.',
|
||||
},
|
||||
},
|
||||
required: ['id', 'userId', 'updatedAt', 'attempts', 'lockedUntil'],
|
||||
},
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was created.',
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
description: 'Username of the account.',
|
||||
},
|
||||
password: {
|
||||
type: 'string',
|
||||
description: 'Password used to authenticate the account.',
|
||||
},
|
||||
role: {
|
||||
type: 'string',
|
||||
description: 'Permission role assigned to the user.',
|
||||
},
|
||||
twoFactorRequired: {
|
||||
type: 'boolean',
|
||||
description: 'Whether two-factor authentication is required.',
|
||||
},
|
||||
websites: {
|
||||
type: 'array',
|
||||
@@ -179,40 +201,51 @@ const operation2 = defineOperation({
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was created.',
|
||||
},
|
||||
updatedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was last updated.',
|
||||
},
|
||||
deletedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was deleted, if applicable.',
|
||||
},
|
||||
createdBy: {
|
||||
type: 'string',
|
||||
description: 'ID of the user who created the resource.',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
description: 'Display name of the resource.',
|
||||
},
|
||||
domain: {
|
||||
type: 'string',
|
||||
description: 'Domain name associated with the resource.',
|
||||
},
|
||||
resetAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the website analytics were last reset.',
|
||||
},
|
||||
teamId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated team.',
|
||||
},
|
||||
recorderEnabled: {
|
||||
type: 'boolean',
|
||||
description: 'Whether recording is enabled for the website.',
|
||||
},
|
||||
replayConfig: {
|
||||
anyOf: [
|
||||
@@ -268,6 +301,7 @@ const operation2 = defineOperation({
|
||||
required: ['length'],
|
||||
},
|
||||
],
|
||||
description: 'Session replay and heatmap recording configuration.',
|
||||
},
|
||||
},
|
||||
required: [
|
||||
@@ -293,40 +327,51 @@ const operation2 = defineOperation({
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was created.',
|
||||
},
|
||||
updatedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was last updated.',
|
||||
},
|
||||
deletedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was deleted, if applicable.',
|
||||
},
|
||||
createdBy: {
|
||||
type: 'string',
|
||||
description: 'ID of the user who created the resource.',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
description: 'Display name of the resource.',
|
||||
},
|
||||
domain: {
|
||||
type: 'string',
|
||||
description: 'Domain name associated with the resource.',
|
||||
},
|
||||
resetAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the website analytics were last reset.',
|
||||
},
|
||||
teamId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated team.',
|
||||
},
|
||||
recorderEnabled: {
|
||||
type: 'boolean',
|
||||
description: 'Whether recording is enabled for the website.',
|
||||
},
|
||||
replayConfig: {
|
||||
anyOf: [
|
||||
@@ -382,6 +427,7 @@ const operation2 = defineOperation({
|
||||
required: ['length'],
|
||||
},
|
||||
],
|
||||
description: 'Session replay and heatmap recording configuration.',
|
||||
},
|
||||
},
|
||||
required: [
|
||||
@@ -399,6 +445,7 @@ const operation2 = defineOperation({
|
||||
'replayConfig',
|
||||
],
|
||||
},
|
||||
description: 'ID of the user who created the resource.',
|
||||
},
|
||||
links: {
|
||||
type: 'array',
|
||||
@@ -407,33 +454,42 @@ const operation2 = defineOperation({
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was created.',
|
||||
},
|
||||
updatedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was last updated.',
|
||||
},
|
||||
deletedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was deleted, if applicable.',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
description: 'Display name of the resource.',
|
||||
},
|
||||
teamId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated team.',
|
||||
},
|
||||
url: {
|
||||
type: 'string',
|
||||
description: 'URL associated with the resource.',
|
||||
},
|
||||
slug: {
|
||||
type: 'string',
|
||||
description: 'URL slug used to access the resource.',
|
||||
},
|
||||
},
|
||||
required: [
|
||||
@@ -448,6 +504,7 @@ const operation2 = defineOperation({
|
||||
'slug',
|
||||
],
|
||||
},
|
||||
description: 'Tracked links associated with the user.',
|
||||
},
|
||||
pixels: {
|
||||
type: 'array',
|
||||
@@ -456,30 +513,38 @@ const operation2 = defineOperation({
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was created.',
|
||||
},
|
||||
updatedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was last updated.',
|
||||
},
|
||||
deletedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was deleted, if applicable.',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
description: 'Display name of the resource.',
|
||||
},
|
||||
teamId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated team.',
|
||||
},
|
||||
slug: {
|
||||
type: 'string',
|
||||
description: 'URL slug used to access the resource.',
|
||||
},
|
||||
},
|
||||
required: [
|
||||
@@ -493,6 +558,7 @@ const operation2 = defineOperation({
|
||||
'slug',
|
||||
],
|
||||
},
|
||||
description: 'Tracking pixels associated with the user.',
|
||||
},
|
||||
teams: {
|
||||
type: 'array',
|
||||
@@ -501,27 +567,34 @@ const operation2 = defineOperation({
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was created.',
|
||||
},
|
||||
updatedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was last updated.',
|
||||
},
|
||||
role: {
|
||||
type: 'string',
|
||||
description: 'Permission role assigned to the user.',
|
||||
},
|
||||
teamId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated team.',
|
||||
},
|
||||
},
|
||||
required: ['id', 'userId', 'createdAt', 'updatedAt', 'role', 'teamId'],
|
||||
},
|
||||
description: 'Teams associated with the user.',
|
||||
},
|
||||
reports: {
|
||||
type: 'array',
|
||||
@@ -530,26 +603,32 @@ const operation2 = defineOperation({
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was created.',
|
||||
},
|
||||
updatedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was last updated.',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
description: 'Display name of the resource.',
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
description: 'Description of the resource.',
|
||||
},
|
||||
parameters: {
|
||||
anyOf: [
|
||||
@@ -605,9 +684,11 @@ const operation2 = defineOperation({
|
||||
required: ['length'],
|
||||
},
|
||||
],
|
||||
description: 'Configuration parameters for the resource.',
|
||||
},
|
||||
websiteId: {
|
||||
type: 'string',
|
||||
description: 'ID of the website.',
|
||||
},
|
||||
},
|
||||
required: [
|
||||
@@ -622,6 +703,7 @@ const operation2 = defineOperation({
|
||||
'websiteId',
|
||||
],
|
||||
},
|
||||
description: 'Saved reports associated with the user.',
|
||||
},
|
||||
boards: {
|
||||
type: 'array',
|
||||
@@ -630,29 +712,36 @@ const operation2 = defineOperation({
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was created.',
|
||||
},
|
||||
updatedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was last updated.',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
description: 'Display name of the resource.',
|
||||
},
|
||||
teamId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated team.',
|
||||
},
|
||||
type: {
|
||||
type: 'string',
|
||||
},
|
||||
description: {
|
||||
type: 'string',
|
||||
description: 'Description of the resource.',
|
||||
},
|
||||
parameters: {
|
||||
anyOf: [
|
||||
@@ -708,6 +797,7 @@ const operation2 = defineOperation({
|
||||
required: ['length'],
|
||||
},
|
||||
],
|
||||
description: 'Configuration parameters for the resource.',
|
||||
},
|
||||
},
|
||||
required: [
|
||||
@@ -722,6 +812,7 @@ const operation2 = defineOperation({
|
||||
'parameters',
|
||||
],
|
||||
},
|
||||
description: 'Boards associated with the user.',
|
||||
},
|
||||
twoFactorBackupCodes: {
|
||||
type: 'array',
|
||||
@@ -730,13 +821,16 @@ const operation2 = defineOperation({
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was created.',
|
||||
},
|
||||
codeHash: {
|
||||
type: 'string',
|
||||
@@ -755,9 +849,11 @@ const operation2 = defineOperation({
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
otp: {
|
||||
type: 'string',
|
||||
@@ -765,6 +861,7 @@ const operation2 = defineOperation({
|
||||
expiresAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the credential expires.',
|
||||
},
|
||||
},
|
||||
required: ['id', 'userId', 'otp', 'expiresAt'],
|
||||
@@ -777,26 +874,32 @@ const operation2 = defineOperation({
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was created.',
|
||||
},
|
||||
name: {
|
||||
type: 'string',
|
||||
description: 'Display name of the resource.',
|
||||
},
|
||||
keyHash: {
|
||||
type: 'string',
|
||||
},
|
||||
keyPrefix: {
|
||||
type: 'string',
|
||||
description: 'Visible prefix used to identify an API key.',
|
||||
},
|
||||
lastUsedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the credential was last used.',
|
||||
},
|
||||
},
|
||||
required: [
|
||||
@@ -809,121 +912,7 @@ const operation2 = defineOperation({
|
||||
'lastUsedAt',
|
||||
],
|
||||
},
|
||||
},
|
||||
oauthAuthorizationCodes: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
},
|
||||
codeHash: {
|
||||
type: 'string',
|
||||
},
|
||||
expiresAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
},
|
||||
clientId: {
|
||||
type: 'string',
|
||||
},
|
||||
redirectUri: {
|
||||
type: 'string',
|
||||
},
|
||||
scope: {
|
||||
type: 'string',
|
||||
},
|
||||
resource: {
|
||||
type: 'string',
|
||||
},
|
||||
codeChallenge: {
|
||||
type: 'string',
|
||||
},
|
||||
codeChallengeMethod: {
|
||||
type: 'string',
|
||||
},
|
||||
usedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
},
|
||||
},
|
||||
required: [
|
||||
'id',
|
||||
'userId',
|
||||
'createdAt',
|
||||
'codeHash',
|
||||
'expiresAt',
|
||||
'clientId',
|
||||
'redirectUri',
|
||||
'scope',
|
||||
'resource',
|
||||
'codeChallenge',
|
||||
'codeChallengeMethod',
|
||||
'usedAt',
|
||||
],
|
||||
},
|
||||
},
|
||||
oauthRefreshTokens: {
|
||||
type: 'array',
|
||||
items: {
|
||||
type: 'object',
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
},
|
||||
userId: {
|
||||
type: 'string',
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
},
|
||||
expiresAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
},
|
||||
lastUsedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
},
|
||||
clientId: {
|
||||
type: 'string',
|
||||
},
|
||||
scope: {
|
||||
type: 'string',
|
||||
},
|
||||
resource: {
|
||||
type: 'string',
|
||||
},
|
||||
tokenHash: {
|
||||
type: 'string',
|
||||
},
|
||||
revokedAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
},
|
||||
},
|
||||
required: [
|
||||
'id',
|
||||
'userId',
|
||||
'createdAt',
|
||||
'expiresAt',
|
||||
'lastUsedAt',
|
||||
'clientId',
|
||||
'scope',
|
||||
'resource',
|
||||
'tokenHash',
|
||||
'revokedAt',
|
||||
],
|
||||
},
|
||||
description: 'API keys associated with the user.',
|
||||
},
|
||||
_count: {
|
||||
type: 'object',
|
||||
@@ -933,21 +922,27 @@ const operation2 = defineOperation({
|
||||
},
|
||||
createdBy: {
|
||||
type: 'number',
|
||||
description: 'ID of the user who created the resource.',
|
||||
},
|
||||
links: {
|
||||
type: 'number',
|
||||
description: 'Tracked links associated with the user.',
|
||||
},
|
||||
pixels: {
|
||||
type: 'number',
|
||||
description: 'Tracking pixels associated with the user.',
|
||||
},
|
||||
teams: {
|
||||
type: 'number',
|
||||
description: 'Teams associated with the user.',
|
||||
},
|
||||
reports: {
|
||||
type: 'number',
|
||||
description: 'Saved reports associated with the user.',
|
||||
},
|
||||
boards: {
|
||||
type: 'number',
|
||||
description: 'Boards associated with the user.',
|
||||
},
|
||||
twoFactorAuth: {
|
||||
type: 'number',
|
||||
@@ -963,12 +958,7 @@ const operation2 = defineOperation({
|
||||
},
|
||||
apiKeys: {
|
||||
type: 'number',
|
||||
},
|
||||
oauthAuthorizationCodes: {
|
||||
type: 'number',
|
||||
},
|
||||
oauthRefreshTokens: {
|
||||
type: 'number',
|
||||
description: 'API keys associated with the user.',
|
||||
},
|
||||
},
|
||||
required: [
|
||||
@@ -984,8 +974,6 @@ const operation2 = defineOperation({
|
||||
'twoFactorOtpUseds',
|
||||
'twoFactorRateLimit',
|
||||
'apiKeys',
|
||||
'oauthAuthorizationCodes',
|
||||
'oauthRefreshTokens',
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -1008,8 +996,6 @@ const operation2 = defineOperation({
|
||||
'twoFactorBackupCodes',
|
||||
'twoFactorOtpUseds',
|
||||
'apiKeys',
|
||||
'oauthAuthorizationCodes',
|
||||
'oauthRefreshTokens',
|
||||
'_count',
|
||||
],
|
||||
},
|
||||
@@ -1044,7 +1030,8 @@ const operation3 = defineOperation({
|
||||
auth: 'bearer',
|
||||
operation: {
|
||||
operationId: 'updateUser',
|
||||
summary: 'Create or update users user id',
|
||||
summary: 'Update a user',
|
||||
description: "Updates a user's password. Administrators can also change the username and role.",
|
||||
tags: ['Users'],
|
||||
parameters: [
|
||||
{
|
||||
@@ -1054,6 +1041,7 @@ const operation3 = defineOperation({
|
||||
schema: {
|
||||
type: 'string',
|
||||
},
|
||||
description: 'ID of the associated user.',
|
||||
},
|
||||
],
|
||||
requestBody: {
|
||||
@@ -1066,15 +1054,18 @@ const operation3 = defineOperation({
|
||||
username: {
|
||||
type: 'string',
|
||||
maxLength: 255,
|
||||
description: 'Username of the account.',
|
||||
},
|
||||
password: {
|
||||
type: 'string',
|
||||
minLength: 8,
|
||||
maxLength: 255,
|
||||
description: 'Password used to authenticate the account.',
|
||||
},
|
||||
role: {
|
||||
type: 'string',
|
||||
enum: ['admin', 'user', 'view-only'],
|
||||
description: 'Permission role assigned to the user.',
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -1091,16 +1082,20 @@ const operation3 = defineOperation({
|
||||
properties: {
|
||||
id: {
|
||||
type: 'string',
|
||||
description: 'Unique identifier of the resource.',
|
||||
},
|
||||
createdAt: {
|
||||
type: 'string',
|
||||
format: 'date-time',
|
||||
description: 'Date and time the record was created.',
|
||||
},
|
||||
username: {
|
||||
type: 'string',
|
||||
description: 'Username of the account.',
|
||||
},
|
||||
role: {
|
||||
type: 'string',
|
||||
description: 'Permission role assigned to the user.',
|
||||
},
|
||||
},
|
||||
required: ['id', 'createdAt', 'username', 'role'],
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'getWebsiteDateRange',
|
||||
summary: 'Get websites website id daterange',
|
||||
tags: ['Websites'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
parameters: [
|
||||
{
|
||||
name: 'websiteId',
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'getEventData',
|
||||
summary: 'Get websites website id event data',
|
||||
tags: ['Websites'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
parameters: [
|
||||
{
|
||||
name: 'websiteId',
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'getEventDataProperties',
|
||||
summary: 'Get websites website id event data properties',
|
||||
tags: ['Websites'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
parameters: [
|
||||
{
|
||||
name: 'websiteId',
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'getEventDataStats',
|
||||
summary: 'Get websites website id event data stats',
|
||||
tags: ['Websites'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
parameters: [
|
||||
{
|
||||
name: 'websiteId',
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'getEventDataValues',
|
||||
summary: 'Get websites website id event data values',
|
||||
tags: ['Websites'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
parameters: [
|
||||
{
|
||||
name: 'websiteId',
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'getWebsiteEventSeries',
|
||||
summary: 'Get websites website id events series',
|
||||
tags: ['Websites'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
parameters: [
|
||||
{
|
||||
name: 'websiteId',
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'getWebsiteEventStats',
|
||||
summary: 'Get websites website id events stats',
|
||||
tags: ['Websites'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
parameters: [
|
||||
{
|
||||
name: 'websiteId',
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'getWebsiteExpandedMetrics',
|
||||
summary: 'Get websites website id metrics expanded',
|
||||
tags: ['Websites'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
parameters: [
|
||||
{
|
||||
name: 'websiteId',
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'getWebsiteSessionActivity',
|
||||
summary: 'Get websites website id sessions session id activity',
|
||||
tags: ['Websites'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
parameters: [
|
||||
{
|
||||
name: 'websiteId',
|
||||
|
||||
@@ -111,7 +111,6 @@ const operation2 = defineOperation({
|
||||
operationId: 'getWebsiteSession',
|
||||
summary: 'Get websites website id sessions session id',
|
||||
tags: ['Websites'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
parameters: [
|
||||
{
|
||||
name: 'websiteId',
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'getWebsiteSessionProperties',
|
||||
summary: 'Get websites website id sessions session id properties',
|
||||
tags: ['Websites'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
parameters: [
|
||||
{
|
||||
name: 'websiteId',
|
||||
|
||||
@@ -12,7 +12,6 @@ const operation1 = defineOperation({
|
||||
operationId: 'getWebsiteSessionStats',
|
||||
summary: 'Get websites website id sessions stats',
|
||||
tags: ['Websites'],
|
||||
'x-umami-oauth-scope': 'analytics:read',
|
||||
parameters: [
|
||||
{
|
||||
name: 'websiteId',
|
||||
|
||||
Reference in new issue
Block a user