Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Microsoft Teams 8.0.0 release#4019

Open
ewilson-r7 wants to merge 3 commits into
masterrapid7/insightconnect-plugins:masterfrom
microsoft-teams-8.0.0-releaserapid7/insightconnect-plugins:microsoft-teams-8.0.0-releaseCopy head branch name to clipboard
Open

Microsoft Teams 8.0.0 release#4019
ewilson-r7 wants to merge 3 commits into
masterrapid7/insightconnect-plugins:masterfrom
microsoft-teams-8.0.0-releaserapid7/insightconnect-plugins:microsoft-teams-8.0.0-releaseCopy head branch name to clipboard

Conversation

@ewilson-r7

Copy link
Copy Markdown
Collaborator

🎫 Ticket

N/A

🧩 Type of Change

  • Feature
  • Bug fix
  • Other

🧠 Background & Motivation

The Microsoft Teams plugin required a user account (ROPC/password grant) to function, which is a security concern and operational burden. This release eliminates that requirement entirely by switching to app-only authentication via client_credentials OAuth2 flow and Bot Framework for sending messages. Additionally, the plugin needed auto-install support so bots can send messages in chats without manual app installation steps.

✨ What Changed

Major refactor to app-only auth (v8.0.0):

  • Switched from ROPC (password grant) to client_credentials OAuth2 flow
  • Added Bot Framework integration for sending messages (no user account needed)
  • Migrated all API calls from /beta to /v1.0 Graph endpoints
  • Removed username_password from connection (breaking change)
  • Removed username input from get_message_in_chat action
  • Added proper API client architecture: BaseClient, GraphApiClient, BotService
  • Added centralized constants module

App Catalog auto-install support:

  • Added app_catalog_id to connection — when configured, the bot auto-installs itself into chats on 403, then retries the send
  • GraphApiClient.install_app_in_chat() handles the install via Graph API
  • send_message action includes _send_chat_message_with_auto_install retry logic

SDK & tooling updates:

  • Bumped SDK from 6.5.1 to 6.6.0
  • Added enable_cache: true to plugin.spec.yaml

🧪 Testing

  • 37+ unit tests passing — all rewritten to mock at client level instead of requests level
  • Added 10 new unit tests for GraphApiClient.create_chat methods (201, 202, polling, payload format, error cases)
  • Added unit tests for bot service auto-install behavior and send_message retry on 403
  • Tested all actions in Staging environment with success.

@ewilson-r7
ewilson-r7 requested a review from a team as a code owner July 17, 2026 13:07
@snyk-io

snyk-io Bot commented Jul 17, 2026

Copy link
Copy Markdown

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@ewilson-r7
ewilson-r7 force-pushed the microsoft-teams-8.0.0-release branch from 2f50bec to b56014a Compare July 17, 2026 14:25

@igorski-r7 igorski-r7 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please update the release branch or rebase it with master

* microsoft_teams: Remove user account requirement, switch to app-only auth

Major refactor (v8.0.0) to eliminate the need for a user account:

- Switch from ROPC (password grant) to client_credentials OAuth2 flow
- Add Bot Framework integration for sending messages (no user needed)
- Migrate all API calls from /beta to /v1.0 Graph endpoints
- Remove username_password from connection (breaking change)
- Remove username input from get_message_in_chat action
- Add proper API client class (graph_api_client.py)
- Add Bot Framework service class (bot_service.py)
- Add centralized constants (constants.py)
- Fix single-tenant bot auth (use tenant ID, not botframework.com)
- Remove spurious tenant_id from Graph API resource paths
- Update SDK to 6.5.1
- Update unit tests to mock at client level instead of requests level

* microsoft_teams: Fix unit tests and prospector issues

- Rewrite all unit tests to mock at client level instead of requests level
- Implement all stub test cases (previously self.fail placeholders)
- Fix mccabe complexity in _send_activity (extract helper methods)
- Fix mccabe complexity in get_teams (extract _build_teams_endpoint,
  _paginate_results, _filter_teams_by_name)
- Remove unused BOT_FRAMEWORK_TOKEN_URL constant (bandit B105)
- Move time.sleep import to top-level (pylint import-outside-toplevel)
- Fix possibly-used-before-assignment in _filter_teams_by_name
- Suppress too-many-arguments on legitimate API method signatures

37 tests passing, 0 prospector issues on util modules.

* fix lint issues

Fix lint issues in unit tests

* microsoft_teams: Address PR review feedback

- Extract BaseClient class (util/base_client.py) with shared OAuth2
  client_credentials auth and HTTP request handling
- GraphApiClient and BotService now inherit from BaseClient
- Move authentication logic out of connection.py into client classes
- Add empty-list guards in all actions that access [0] index:
  get_channels_for_team, send_html_message, add_channel_to_team,
  remove_channel_from_team (prevents IndexError on empty results)
- Fix super() call in Connection (use modern syntax)
- Expose public authenticate() and get_auth_headers() on BaseClient
- Remove unused TIMEOUT imports from subclasses
- All 37 tests passing, 0 prospector issues

* PR Feedback updates

* Address PR Feedback

* Fix Version History to include updates from previous commit

* trigger diff recalc
* Add installed_apps support to create_teams_chat action

Added optional installed_apps input to the create_teams_chat action, allowing
users to install apps (e.g. bots) into a chat at creation time via the
Microsoft Graph API's installedApps property.

This is required for bots to send messages in chats — they cannot be added as
regular members and must be installed as apps instead.

Changes:
- plugin.spec.yaml: Added installed_apps input (type []string) to create_teams_chat
- schema.py: Added INSTALLED_APPS constant and updated input JSON schema
- action.py: Passes installed_apps through to the Graph API client
- graph_api_client.py: Updated create_chat to format installedApps payload and
  handle the 202 Accepted async response (direct chat fetch with polling fallback)
- unit tests: Added test cases for installed_apps with oneOnOne and group chats
- test samples: Populated connection credentials across all test JSON files

* Prospector/Pylint fixes

MC0001 complexity (was 11) → Extracted _build_chat_payload from create_chat — now well under threshold
too-many-branches (was 19/15) → Split _handle_async_chat_creation into 5 focused methods: _try_direct_chat_fetch, _poll_chat_operation, _process_poll_response, _final_chat_fetch_or_partial, and the existing _extract_chat_id_from_location
unreachable code → Removed the duplicate raise PluginException block
import-outside-toplevel / reimported re → Removed the import re from inside _extract_chat_id_from_location (it's already at the top of the file)
Coverage fixes:

Added 10 new unit tests in TestGraphApiClientCreateChat that directly test the GraphApiClient methods (201, 202 direct fetch, 202 polling, payload format, error cases, location header parsing)
New code has 100% test coverage

* Add install_app action

New action - install_app:
- Accepts team_id or chat_id (mutually exclusive) and an app_id
- Calls POST /teams/{id}/installedApps or POST /chats/{id}/installedApps
- Validates that exactly one target is provided

* Refactor Install Apps Behavior

Connection
Added app_catalog_id (optional) — When configured, the bot automatically installs itself into chats on 403, eliminating manual steps
Bot Service (bot_service.py)
Constructor now accepts graph_client and app_catalog_id parameters
send_chat_message — on 403, if app_catalog_id is configured, auto-installs the bot in the chat via Graph API and retries the send
Refactored _send_activity into _send_activity + _send_activity_raw to allow inspecting the response status before handling
Graph API Client (graph_api_client.py)
create_chat — simplified back to synchronous-only (no more installed_apps param or 202 async handling)
Removed: _handle_async_chat_creation, _try_direct_chat_fetch, _poll_chat_operation, _process_poll_response, _final_chat_fetch_or_partial, _extract_chat_id_from_location, install_app_in_team
Kept: install_app_in_chat (used internally by bot service auto-install)
Actions
create_teams_chat — removed installed_apps input (redundant with connection-level auto-install)
install_app — removed entirely (action, schema, tests, sample)

* Update changelog

* Refactor Bot Install

bot_service.py — back to a clean, standalone service. No graph_client or app_catalog_id references. Just sends messages and raises PluginException on 403.
connection.py — stores app_catalog_id as a connection-level attribute (self.connection.app_catalog_id)
action.py
 — new _send_chat_message_with_auto_install method catches the 403 PluginException, checks if app_catalog_id is configured, calls self.connection.client.install_app_in_chat(), and retries the send.

* Update app cat usage

app_catalog_id now lives on GraphApiClient (as self.app_catalog_id)
install_app_in_chat(chat_id) no longer takes an app_id parameter — it uses the internally stored self.app_catalog_id
Connection passes app_catalog_id to GraphApiClient.__init__
The action code is now simplified
* Bump SDK to 6.6.0 and add enable_cache entry

* Set enable_cache to true.
@ewilson-r7
ewilson-r7 force-pushed the microsoft-teams-8.0.0-release branch from b56014a to de744ed Compare July 24, 2026 14:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.