mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-19 01:40:15 +01:00
✔️ fix: Resource field TypeError & Missing Role Permission Type (#8606)
* fix: resource parameter undefined TypeError in log * chore: Add missing FILE_SEARCH permission type to IRole interface * chore: Bump version of @librechat/data-schemas to 0.0.11 * fix: Ensure resource is defined and handle potential null values in OAuth flow
This commit is contained in:
parent
baf3b4ad08
commit
62c3f135e7
4 changed files with 14 additions and 12 deletions
2
package-lock.json
generated
2
package-lock.json
generated
|
|
@ -48815,7 +48815,7 @@
|
||||||
},
|
},
|
||||||
"packages/data-schemas": {
|
"packages/data-schemas": {
|
||||||
"name": "@librechat/data-schemas",
|
"name": "@librechat/data-schemas",
|
||||||
"version": "0.0.10",
|
"version": "0.0.11",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@rollup/plugin-alias": "^5.1.0",
|
"@rollup/plugin-alias": "^5.1.0",
|
||||||
|
|
|
||||||
|
|
@ -269,18 +269,17 @@ export class MCPOAuthHandler {
|
||||||
authorizationUrl.searchParams.set('state', flowId);
|
authorizationUrl.searchParams.set('state', flowId);
|
||||||
logger.debug(`[MCPOAuth] Added state parameter to authorization URL`);
|
logger.debug(`[MCPOAuth] Added state parameter to authorization URL`);
|
||||||
|
|
||||||
if (resourceMetadata?.resource) {
|
if (resourceMetadata?.resource != null && resourceMetadata.resource) {
|
||||||
authorizationUrl.searchParams.set('resource', resourceMetadata.resource);
|
authorizationUrl.searchParams.set('resource', resourceMetadata.resource);
|
||||||
|
logger.debug(
|
||||||
|
`[MCPOAuth] Added resource parameter to authorization URL: ${resourceMetadata.resource}`,
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
`[MCPOAuth] Resource metadata missing 'resource' property for ${serverName}. ` +
|
`[MCPOAuth] Resource metadata missing 'resource' property for ${serverName}. ` +
|
||||||
'This can cause issues with some Authorization Servers who expect a "resource" parameter.',
|
'This can cause issues with some Authorization Servers who expect a "resource" parameter.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.debug(
|
|
||||||
`[MCPOAuth] Added resource parameter to authorization URL: ${resourceMetadata.resource}`,
|
|
||||||
);
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(`[MCPOAuth] startAuthorization failed:`, error);
|
logger.error(`[MCPOAuth] startAuthorization failed:`, error);
|
||||||
throw error;
|
throw error;
|
||||||
|
|
@ -343,9 +342,9 @@ export class MCPOAuthHandler {
|
||||||
throw new Error('Invalid flow metadata');
|
throw new Error('Invalid flow metadata');
|
||||||
}
|
}
|
||||||
|
|
||||||
let resource;
|
let resource: URL | undefined;
|
||||||
try {
|
try {
|
||||||
if (metadata.resourceMetadata?.resource) {
|
if (metadata.resourceMetadata?.resource != null && metadata.resourceMetadata.resource) {
|
||||||
resource = new URL(metadata.resourceMetadata.resource);
|
resource = new URL(metadata.resourceMetadata.resource);
|
||||||
logger.debug(`[MCPOAuth] Resource URL for flow ${flowId}: ${resource.toString()}`);
|
logger.debug(`[MCPOAuth] Resource URL for flow ${flowId}: ${resource.toString()}`);
|
||||||
}
|
}
|
||||||
|
|
@ -358,12 +357,12 @@ export class MCPOAuthHandler {
|
||||||
}
|
}
|
||||||
|
|
||||||
const tokens = await exchangeAuthorization(metadata.serverUrl, {
|
const tokens = await exchangeAuthorization(metadata.serverUrl, {
|
||||||
|
redirectUri: metadata.clientInfo.redirect_uris?.[0] || this.getDefaultRedirectUri(),
|
||||||
metadata: metadata.metadata as unknown as SDKOAuthMetadata,
|
metadata: metadata.metadata as unknown as SDKOAuthMetadata,
|
||||||
clientInformation: metadata.clientInfo,
|
clientInformation: metadata.clientInfo,
|
||||||
authorizationCode,
|
|
||||||
codeVerifier: metadata.codeVerifier,
|
codeVerifier: metadata.codeVerifier,
|
||||||
redirectUri: metadata.clientInfo.redirect_uris?.[0] || this.getDefaultRedirectUri(),
|
authorizationCode,
|
||||||
resource: resource,
|
resource,
|
||||||
});
|
});
|
||||||
|
|
||||||
logger.debug('[MCPOAuth] Raw tokens from exchange:', {
|
logger.debug('[MCPOAuth] Raw tokens from exchange:', {
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@librechat/data-schemas",
|
"name": "@librechat/data-schemas",
|
||||||
"version": "0.0.10",
|
"version": "0.0.11",
|
||||||
"description": "Mongoose schemas and models for LibreChat",
|
"description": "Mongoose schemas and models for LibreChat",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"main": "dist/index.cjs",
|
"main": "dist/index.cjs",
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,8 @@ export interface IRole extends Document {
|
||||||
[PermissionTypes.WEB_SEARCH]?: {
|
[PermissionTypes.WEB_SEARCH]?: {
|
||||||
[Permissions.USE]?: boolean;
|
[Permissions.USE]?: boolean;
|
||||||
};
|
};
|
||||||
|
[PermissionTypes.FILE_SEARCH]?: {
|
||||||
|
[Permissions.USE]?: boolean;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue