Add OAuth-protected MCP server with generated API client packages
This commit is contained in:
1 parent
26e236c95c
commit
65bf19e067
235 files changed
+33755
-3199
No files matched your search
+24
-4
@@ -1,3 +1,4 @@
|
||||
import { OAUTH_SCOPE_DESCRIPTIONS, type OAuthScope } from '@/lib/oauth/scopes';
|
||||
import type { ApiAuth } from '@/openapi/operation';
|
||||
|
||||
export const securitySchemes = {
|
||||
@@ -8,6 +9,19 @@ export const securitySchemes = {
|
||||
description:
|
||||
'Token returned by POST /api/auth/login, or an API key (`umami_…`) created under Settings → API keys (self-hosted only).',
|
||||
},
|
||||
oauth2: {
|
||||
type: 'oauth2' as const,
|
||||
description:
|
||||
'OAuth 2.1 access token (authorization code + PKCE). Only operations that declare an OAuth scope accept these tokens.',
|
||||
flows: {
|
||||
authorizationCode: {
|
||||
authorizationUrl: '/oauth/authorize',
|
||||
tokenUrl: '/api/oauth/token',
|
||||
refreshUrl: '/api/oauth/token',
|
||||
scopes: OAUTH_SCOPE_DESCRIPTIONS,
|
||||
},
|
||||
},
|
||||
},
|
||||
shareToken: {
|
||||
type: 'apiKey' as const,
|
||||
in: 'header' as const,
|
||||
@@ -22,14 +36,20 @@ export const securitySchemes = {
|
||||
},
|
||||
};
|
||||
|
||||
export function getSecurityRequirements(auth: ApiAuth) {
|
||||
export function getSecurityRequirements(auth: ApiAuth, scope?: OAuthScope | null) {
|
||||
if (auth === 'none') {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (auth === 'bearer-or-share') {
|
||||
return [{ bearerAuth: [] }, { shareToken: [], shareContext: [] }];
|
||||
const requirements: Record<string, string[]>[] = [{ bearerAuth: [] }];
|
||||
|
||||
if (scope) {
|
||||
requirements.push({ oauth2: [scope] });
|
||||
}
|
||||
|
||||
return [{ bearerAuth: [] }];
|
||||
if (auth === 'bearer-or-share') {
|
||||
requirements.push({ shareToken: [], shareContext: [] });
|
||||
}
|
||||
|
||||
return requirements;
|
||||
}
|
||||
Reference in new issue
Block a user