mirror of
https://github.com/open-webui/open-webui
synced 2025-06-11 17:02:47 +00:00
Add SharePoint tenant ID to OneDrive settings
This commit is contained in:
parent
23b9354cf6
commit
4ca0ea1e55
@ -1824,6 +1824,11 @@ ONEDRIVE_SHAREPOINT_URL = PersistentConfig(
|
|||||||
os.environ.get("ONEDRIVE_SHAREPOINT_URL", ""),
|
os.environ.get("ONEDRIVE_SHAREPOINT_URL", ""),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
ONEDRIVE_SHAREPOINT_TENANT_ID = PersistentConfig(
|
||||||
|
"ONEDRIVE_SHAREPOINT_TENANT_ID",
|
||||||
|
"onedrive.sharepoint_tenant_id",
|
||||||
|
os.environ.get("ONEDRIVE_SHAREPOINT_TENANT_ID", ""),
|
||||||
|
)
|
||||||
|
|
||||||
# RAG Content Extraction
|
# RAG Content Extraction
|
||||||
CONTENT_EXTRACTION_ENGINE = PersistentConfig(
|
CONTENT_EXTRACTION_ENGINE = PersistentConfig(
|
||||||
|
@ -103,6 +103,7 @@ from open_webui.config import (
|
|||||||
ENABLE_OPENAI_API,
|
ENABLE_OPENAI_API,
|
||||||
ONEDRIVE_CLIENT_ID,
|
ONEDRIVE_CLIENT_ID,
|
||||||
ONEDRIVE_SHAREPOINT_URL,
|
ONEDRIVE_SHAREPOINT_URL,
|
||||||
|
ONEDRIVE_SHAREPOINT_TENANT_ID,
|
||||||
OPENAI_API_BASE_URLS,
|
OPENAI_API_BASE_URLS,
|
||||||
OPENAI_API_KEYS,
|
OPENAI_API_KEYS,
|
||||||
OPENAI_API_CONFIGS,
|
OPENAI_API_CONFIGS,
|
||||||
@ -254,6 +255,7 @@ from open_webui.config import (
|
|||||||
GOOGLE_DRIVE_API_KEY,
|
GOOGLE_DRIVE_API_KEY,
|
||||||
ONEDRIVE_CLIENT_ID,
|
ONEDRIVE_CLIENT_ID,
|
||||||
ONEDRIVE_SHAREPOINT_URL,
|
ONEDRIVE_SHAREPOINT_URL,
|
||||||
|
ONEDRIVE_SHAREPOINT_TENANT_ID,
|
||||||
ENABLE_RAG_HYBRID_SEARCH,
|
ENABLE_RAG_HYBRID_SEARCH,
|
||||||
ENABLE_RAG_LOCAL_WEB_FETCH,
|
ENABLE_RAG_LOCAL_WEB_FETCH,
|
||||||
ENABLE_WEB_LOADER_SSL_VERIFICATION,
|
ENABLE_WEB_LOADER_SSL_VERIFICATION,
|
||||||
@ -1379,6 +1381,7 @@ async def get_app_config(request: Request):
|
|||||||
"onedrive": {
|
"onedrive": {
|
||||||
"client_id": ONEDRIVE_CLIENT_ID.value,
|
"client_id": ONEDRIVE_CLIENT_ID.value,
|
||||||
"sharepoint_url": ONEDRIVE_SHAREPOINT_URL.value,
|
"sharepoint_url": ONEDRIVE_SHAREPOINT_URL.value,
|
||||||
|
"sharepoint_tenant_id": ONEDRIVE_SHAREPOINT_TENANT_ID.value,
|
||||||
},
|
},
|
||||||
"license_metadata": app.state.LICENSE_METADATA,
|
"license_metadata": app.state.LICENSE_METADATA,
|
||||||
**(
|
**(
|
||||||
|
@ -6,6 +6,7 @@ class OneDriveConfig {
|
|||||||
private static instance: OneDriveConfig;
|
private static instance: OneDriveConfig;
|
||||||
private clientId: string = '';
|
private clientId: string = '';
|
||||||
private sharepointUrl: string = '';
|
private sharepointUrl: string = '';
|
||||||
|
private sharepointTenantId: string = '';
|
||||||
private msalInstance: PublicClientApplication | null = null;
|
private msalInstance: PublicClientApplication | null = null;
|
||||||
private currentAuthorityType: 'personal' | 'organizations' = 'personal';
|
private currentAuthorityType: 'personal' | 'organizations' = 'personal';
|
||||||
|
|
||||||
@ -39,7 +40,7 @@ class OneDriveConfig {
|
|||||||
headers,
|
headers,
|
||||||
credentials: 'include'
|
credentials: 'include'
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
throw new Error('Failed to fetch OneDrive credentials');
|
throw new Error('Failed to fetch OneDrive credentials');
|
||||||
}
|
}
|
||||||
@ -48,6 +49,7 @@ class OneDriveConfig {
|
|||||||
|
|
||||||
const newClientId = config.onedrive?.client_id;
|
const newClientId = config.onedrive?.client_id;
|
||||||
const newSharepointUrl = config.onedrive?.sharepoint_url;
|
const newSharepointUrl = config.onedrive?.sharepoint_url;
|
||||||
|
const newSharepointTenantId = config.onedrive?.sharepoint_tenant_id;
|
||||||
|
|
||||||
if (!newClientId) {
|
if (!newClientId) {
|
||||||
throw new Error('OneDrive configuration is incomplete');
|
throw new Error('OneDrive configuration is incomplete');
|
||||||
@ -55,6 +57,7 @@ class OneDriveConfig {
|
|||||||
|
|
||||||
this.clientId = newClientId;
|
this.clientId = newClientId;
|
||||||
this.sharepointUrl = newSharepointUrl;
|
this.sharepointUrl = newSharepointUrl;
|
||||||
|
this.sharepointTenantId = newSharepointTenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getMsalInstance(
|
public async getMsalInstance(
|
||||||
@ -63,8 +66,9 @@ class OneDriveConfig {
|
|||||||
await this.ensureInitialized(authorityType);
|
await this.ensureInitialized(authorityType);
|
||||||
|
|
||||||
if (!this.msalInstance) {
|
if (!this.msalInstance) {
|
||||||
const authorityEndpoint =
|
const authorityEndpoint = this.currentAuthorityType === 'organizations'
|
||||||
this.currentAuthorityType === 'organizations' ? 'common' : 'consumers';
|
? (this.sharepointTenantId || 'common')
|
||||||
|
: 'consumers';
|
||||||
const msalParams = {
|
const msalParams = {
|
||||||
auth: {
|
auth: {
|
||||||
authority: `https://login.microsoftonline.com/${authorityEndpoint}`,
|
authority: `https://login.microsoftonline.com/${authorityEndpoint}`,
|
||||||
@ -89,6 +93,10 @@ class OneDriveConfig {
|
|||||||
return this.sharepointUrl;
|
return this.sharepointUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public getSharepointTenantId(): string {
|
||||||
|
return this.sharepointTenantId;
|
||||||
|
}
|
||||||
|
|
||||||
public getBaseUrl(): string {
|
public getBaseUrl(): string {
|
||||||
if (this.currentAuthorityType === 'organizations') {
|
if (this.currentAuthorityType === 'organizations') {
|
||||||
if (!this.sharepointUrl || this.sharepointUrl === '') {
|
if (!this.sharepointUrl || this.sharepointUrl === '') {
|
||||||
|
Loading…
Reference in New Issue
Block a user