diff --git a/Common/Server/EnvironmentConfig.ts b/Common/Server/EnvironmentConfig.ts index f8216f2629..e0117366f1 100644 --- a/Common/Server/EnvironmentConfig.ts +++ b/Common/Server/EnvironmentConfig.ts @@ -455,6 +455,8 @@ export const MicrosoftTeamsAppClientId: string | null = process.env["MICROSOFT_TEAMS_APP_CLIENT_ID"] || null; export const MicrosoftTeamsAppClientSecret: string | null = process.env["MICROSOFT_TEAMS_APP_CLIENT_SECRET"] || null; +export const MicrosoftTeamsAppTenantId: string | null = + process.env["MICROSOFT_TEAMS_APP_TENANT_ID"] || null; // VAPID Configuration for Web Push Notifications export const VapidPublicKey: string | undefined = diff --git a/Common/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts b/Common/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts index eb302c5bd0..56ec42d84f 100644 --- a/Common/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +++ b/Common/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts @@ -43,6 +43,7 @@ import OneUptimeDate from "../../../../Types/Date"; import { MicrosoftTeamsAppClientId, MicrosoftTeamsAppClientSecret, + MicrosoftTeamsAppTenantId, } from "../../../EnvironmentConfig"; // Import services for bot commands @@ -94,15 +95,17 @@ export default class MicrosoftTeamsUtil extends WorkspaceBase { private static readonly WELCOME_CARD_STATE_KEY: string = "oneuptime.microsoftTeams.welcomeCardSent"; // Get or create Bot Framework adapter for a specific tenant - private static getBotAdapter(microsoftAppTenantId: string): CloudAdapter { + private static getBotAdapter(): CloudAdapter { if (!MicrosoftTeamsAppClientId || !MicrosoftTeamsAppClientSecret) { throw new BadDataException( "Microsoft Teams App credentials not configured", ); } - if (!microsoftAppTenantId) { - throw new BadDataException("Microsoft Teams tenant ID is required"); + if (!MicrosoftTeamsAppTenantId) { + throw new BadDataException( + "Microsoft Teams app tenant ID is not configured", + ); } logger.debug( @@ -110,13 +113,13 @@ export default class MicrosoftTeamsUtil extends WorkspaceBase { ); logger.debug(`App ID: ${MicrosoftTeamsAppClientId}`); logger.debug(`App Type: ${MICROSOFT_TEAMS_APP_TYPE}`); - logger.debug(`Tenant ID: ${microsoftAppTenantId}`); + logger.debug(`Tenant ID: ${MicrosoftTeamsAppTenantId}`); const authConfig: ConfigurationBotFrameworkAuthenticationOptions = { MicrosoftAppId: MicrosoftTeamsAppClientId, MicrosoftAppPassword: MicrosoftTeamsAppClientSecret, MicrosoftAppType: MICROSOFT_TEAMS_APP_TYPE, - MicrosoftAppTenantId: microsoftAppTenantId, + MicrosoftAppTenantId: MicrosoftTeamsAppTenantId, }; const botFrameworkAuthentication: ConfigurationBotFrameworkAuthentication = @@ -1141,7 +1144,7 @@ export default class MicrosoftTeamsUtil extends WorkspaceBase { logger.debug(`Using bot ID: ${miscData.botId}`); // Get Bot Framework adapter - const adapter: CloudAdapter = this.getBotAdapter(tenantId); + const adapter: CloudAdapter = this.getBotAdapter(); // Create conversation reference for the channel const conversationReference: ConversationReference = { @@ -2564,7 +2567,7 @@ All monitoring checks are passing normally.`; } // Get Bot Framework adapter - const adapter: CloudAdapter = this.getBotAdapter(tenantId); + const adapter: CloudAdapter = this.getBotAdapter(); // Create custom activity handler class that extends TeamsActivityHandler class OneUptimeTeamsActivityHandler extends TeamsActivityHandler { diff --git a/Dashboard/src/Components/MicrosoftTeams/MicrosoftTeamsIntegrationDocumentation.tsx b/Dashboard/src/Components/MicrosoftTeams/MicrosoftTeamsIntegrationDocumentation.tsx index a45c5df198..324276f7b5 100644 --- a/Dashboard/src/Components/MicrosoftTeams/MicrosoftTeamsIntegrationDocumentation.tsx +++ b/Dashboard/src/Components/MicrosoftTeams/MicrosoftTeamsIntegrationDocumentation.tsx @@ -87,6 +87,7 @@ If you are using Docker Compose then, \`\`\`bash MICROSOFT_TEAMS_APP_CLIENT_ID=YOUR_TEAMS_APP_CLIENT_ID MICROSOFT_TEAMS_APP_CLIENT_SECRET=YOUR_TEAMS_APP_CLIENT_SECRET +MICROSOFT_TEAMS_APP_TENANT_ID=YOUR_MICROSOFT_TENANT_ID \`\`\` If you are using Kubernetes with Helm then, add these to your \`values.yaml\` file @@ -95,6 +96,7 @@ If you are using Kubernetes with Helm then, add these to your \`values.yaml\` fi microsoftTeamsApp: clientId: clientSecret: + tenantId: \`\`\` diff --git a/Docs/Content/self-hosted/microsoft-teams-integration.md b/Docs/Content/self-hosted/microsoft-teams-integration.md index c3297c68d6..87d68bc651 100644 --- a/Docs/Content/self-hosted/microsoft-teams-integration.md +++ b/Docs/Content/self-hosted/microsoft-teams-integration.md @@ -86,6 +86,7 @@ If you are using Docker Compose, add these environment variables to your configu ```bash MICROSOFT_TEAMS_APP_CLIENT_ID=YOUR_TEAMS_APP_CLIENT_ID MICROSOFT_TEAMS_APP_CLIENT_SECRET=YOUR_TEAMS_APP_CLIENT_SECRET +MICROSOFT_TEAMS_APP_TENANT_ID=YOUR_MICROSOFT_TENANT_ID ``` #### Kubernetes with Helm @@ -96,6 +97,7 @@ If you are using Kubernetes with Helm, add these to your `values.yaml` file: microsoftTeamsApp: clientId: YOUR_TEAMS_APP_CLIENT_ID clientSecret: YOUR_TEAMS_APP_CLIENT_SECRET + tenantId: YOUR_MICROSOFT_TENANT_ID ``` **Important:** Restart your OneUptime server after adding these environment variables so they take effect. diff --git a/HelmChart/Public/oneuptime/templates/_helpers.tpl b/HelmChart/Public/oneuptime/templates/_helpers.tpl index 65f4349171..00aadfdeba 100644 --- a/HelmChart/Public/oneuptime/templates/_helpers.tpl +++ b/HelmChart/Public/oneuptime/templates/_helpers.tpl @@ -40,6 +40,8 @@ Usage: value: {{ (ternary "true" "false" $isEnterpriseEdition) | squote }} - name: MICROSOFT_TEAMS_APP_CLIENT_ID value: {{ $.Values.microsoftTeamsApp.clientId }} +- name: MICROSOFT_TEAMS_APP_TENANT_ID + value: {{ $.Values.microsoftTeamsApp.tenantId }} {{- if $.Values.openTelemetryExporter.endpoint }} - name: OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT diff --git a/HelmChart/Public/oneuptime/values.schema.json b/HelmChart/Public/oneuptime/values.schema.json index 3f0df343b0..78e5c00f1b 100644 --- a/HelmChart/Public/oneuptime/values.schema.json +++ b/HelmChart/Public/oneuptime/values.schema.json @@ -2004,6 +2004,9 @@ }, "clientSecret": { "type": ["string", "null"] + }, + "tenantId": { + "type": ["string", "null"] } }, "additionalProperties": false diff --git a/HelmChart/Public/oneuptime/values.yaml b/HelmChart/Public/oneuptime/values.yaml index 31740e582e..5fe9aa6609 100644 --- a/HelmChart/Public/oneuptime/values.yaml +++ b/HelmChart/Public/oneuptime/values.yaml @@ -795,6 +795,7 @@ slackApp: microsoftTeamsApp: clientId: clientSecret: + tenantId: keda: enabled: true diff --git a/config.example.env b/config.example.env index f59ea95263..229265f362 100644 --- a/config.example.env +++ b/config.example.env @@ -355,4 +355,5 @@ NGINX_LISTEN_OPTIONS= # IMPORTANT: Use the SECRET VALUE, not the SECRET ID from Azure App Registration # The secret value is typically longer and includes more characters MICROSOFT_TEAMS_APP_CLIENT_ID= -MICROSOFT_TEAMS_APP_CLIENT_SECRET= \ No newline at end of file +MICROSOFT_TEAMS_APP_CLIENT_SECRET= +MICROSOFT_TEAMS_APP_TENANT_ID= \ No newline at end of file diff --git a/docker-compose.base.yml b/docker-compose.base.yml index f4a9c2b089..8167b9e982 100644 --- a/docker-compose.base.yml +++ b/docker-compose.base.yml @@ -72,6 +72,7 @@ x-common-variables: &common-variables MICROSOFT_TEAMS_APP_CLIENT_ID: ${MICROSOFT_TEAMS_APP_CLIENT_ID} + MICROSOFT_TEAMS_APP_TENANT_ID: ${MICROSOFT_TEAMS_APP_TENANT_ID} x-common-runtime-variables: &common-runtime-variables <<: *common-variables