mirror of
https://github.com/tiennm99/DocsGPT.git
synced 2026-10-20 02:16:39 +00:00
Connections own their credentials
Migration 0038 moves every stored secret (OAuth tokens, MCP OAuth tokens and client registrations, API keys) into the connection's encrypted envelope, links API-key tools to one connection per distinct credential, allows several accounts per provider, and adds credential_mode to sources and tools. OAuth MCP tools keep resolving each member's own token, as they did before. docsgpt.connectors.service is now the only reader of OAuth tokens: get_valid_token_info refreshes under a row lock and persists rotated refresh tokens, and a revoked grant flags the connection, pauses its sources and notifies the owner. Loaders build from a connection (BaseConnectorLoader.from_connection), so scheduled sync covers Drive, SharePoint and Confluence sources with no browser. S3 and Reddit keys stay on the connection instead of in remote_data. New endpoints: POST /api/connections, /setup, /reconnect, /picker-token, /claim, DELETE /api/connections/<id>, per-action permissions and MCP refresh-tools. Upload, file listing, sync and validate-session take a connection_id; session tokens keep working for this release. The tool executor reads credentials from the resolved connection (owner or member mode) and pauses on a Connect card when a connection needs signing in. docsgpt connectors reencrypt rewrites stored credentials after a key rotation.
This commit is contained in:
1 parent
667d4bbab0
commit
3511004f50
54 files changed
+4007
-754
No files matched your search
@@ -219,6 +219,8 @@ user_tools_table = Table(
|
||||
Column(
|
||||
"connection_id", UUID(as_uuid=True), ForeignKey("connector_sessions.id", ondelete="SET NULL"),
|
||||
),
|
||||
# Whose account a shared resource runs with: the owner's, or each member's.
|
||||
Column("credential_mode", Text, nullable=False, server_default="owner"),
|
||||
)
|
||||
|
||||
token_usage_table = Table(
|
||||
@@ -344,6 +346,8 @@ sources_table = Table(
|
||||
Column(
|
||||
"connection_id", UUID(as_uuid=True), ForeignKey("connector_sessions.id", ondelete="SET NULL"),
|
||||
),
|
||||
# Whose account a shared resource runs with: the owner's, or each member's.
|
||||
Column("credential_mode", Text, nullable=False, server_default="owner"),
|
||||
)
|
||||
|
||||
agents_table = Table(
|
||||
@@ -598,6 +602,12 @@ connector_sessions_table = Table(
|
||||
Column("account_label", Text),
|
||||
Column("auth_kind", Text),
|
||||
Column("updated_at", DateTime(timezone=True), nullable=False, server_default=func.now()),
|
||||
# Every secret of the connection, as one owner-bound v2 envelope.
|
||||
Column("encrypted_credentials", Text),
|
||||
Column("has_refresh_token", Boolean, nullable=False, server_default="false"),
|
||||
Column("scopes", JSONB, nullable=False, server_default="[]"),
|
||||
Column("last_error", Text),
|
||||
Column("last_used_at", DateTime(timezone=True)),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user