Skip to content

feat(connections): add reusable authorization connections system#163

Open
RishadAlam wants to merge 60 commits into
mainfrom
feat/connection-system
Open

feat(connections): add reusable authorization connections system#163
RishadAlam wants to merge 60 commits into
mainfrom
feat/connection-system

Conversation

@RishadAlam
Copy link
Copy Markdown
Member

Description

This PR introduces a reusable connection system for integration authorization across Bit Integrations. It centralizes credential management, adds secure credential storage with encryption, and refactors integrations to use shared authorization flows instead of per-integration auth logic.

Motivation & Context

Many integrations previously handled authorization independently, which caused duplicated logic, inconsistent behavior, and repeated credential entry across flows. This change creates a unified connection layer so users can save and reuse credentials per app, while improving security and maintainability.

Related Links: (if applicable)

N/A

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📚 Documentation update
  • ⚡ Improvement
  • 🔄 Code refactor

Key Changes

Backend (Connection System & Security)

  • Added btcbi_connections storage model/table and DB migration updates for reusable saved credentials.
  • Added ConnectionController endpoints for authorize, oauth token exchange, plugin activation verify, list/get/save/update/reauthorize/delete.
  • Added centralized authorization architecture:
    • AbstractBaseAuthorization
    • AuthorizationFactory
    • auth handlers for API key, Basic, Bearer, OAuth1, OAuth2, and custom auth classes
  • Added secure auth data handling via AuthDataCodec + encrypted key support and Hash utility.
  • Added CredentialInjector to inject resolved connection credentials into flow execution runtime.
  • Added PluginCheck utility to validate plugin availability using grouped AND/OR rules.
  • Updated connection list responses to avoid exposing decrypted credential payloads.

Backend (Integrations Refactor)

  • Refactored many action controllers to declare shared authConfig mappings for standardized credential injection.
  • Removed/Reduced legacy per-integration authorization route handlers and old auth-specific controller methods where replaced by shared connection APIs.
  • Added custom KirimEmailAuthorization handler for its signature-based auth flow.
  • Updated admin menu with a dedicated Connections page link.

Frontend (Connections UI & Shared Auth UX)

  • Added /connections page with connection listing, app filter, rename, delete, and bulk delete actions.
  • Added reusable connection authorization UI components:
    • Authorization
    • ConnectionAccountSelect
    • AddNewConnection
    • ApiConnection
    • Oauth1Connection
    • Oauth2Connection
  • Added connection utility APIs and shared auth constants/helpers.
  • Added OAuth helper flow with popup + BroadcastChannel callback handling, PKCE support, and server-side token exchange integration.
  • Refactored many integration authorization components to use the shared Connections authorization components.
  • Updated styles for new connections management screens and controls.

Checklist

  • Code follows project style guidelines
  • Self-review completed
  • Tests added/updated
  • Documentation updated if needed
  • README updated if needed

Changelog

  • Feature: You can now save and reuse app connections instead of re-authorizing credentials for every integration flow.
  • Feature: Added a dedicated Connections management screen to view, filter, rename, and remove saved connections.
  • Improvement: OAuth/API/Basic/Bearer authorization flows are now unified under one shared system for more consistent setup behavior.
  • Improvement: Sensitive connection credentials are stored with field-level encryption and safer response handling.
  • Improvement: Integrations now use centralized auth mapping/injection, reducing duplicate auth logic and improving long-term reliability.

RishadAlam added 30 commits May 2, 2026 16:14
- Added AuthorizationType class to define various authorization methods.
- Implemented BasicAuthorization for basic authentication handling.
- Created BearerTokenAuthorization for bearer token management.
- Developed OAuth2Authorization to handle OAuth2 flows, including token refresh.
- Introduced ConnectionModel for database interactions related to connections.
- Added Hash utility for encrypting and decrypting sensitive data.
- Created ConnectionController to manage connection CRUD operations.
- Developed frontend API utilities for connection management.
- Implemented ConnectionAccountList and ConnectionAccountSelect components for displaying and managing connections.
- Created Connections page for listing, searching, and managing connections.
…r, connectionApi, MailChimp components, and ConnectionAccountSelect
…ncryption, SSL verification, and nested data access
…ation

- Replaced individual authorization logic in Voxel, WCAffiliate, WPCafe, WPCourseware, WPForo, WishlistMember, WooCommerce, and WP ERP components with a unified PlatformAuthorization component.
- Removed unnecessary state management and input handling from the individual components.
- Updated the styling of the app to improve layout consistency.
- Ensured that each integration checks for the required plugins and provides appropriate notes for users.
- Introduced a new authorization type `WP_PLUGIN_CHECK` in AuthorizationType.php.
- Updated ConnectionController to handle `WP_PLUGIN_CHECK` by returning appropriate error messages.
- Modified frontend components to use `WP_PLUGIN_CHECK` as the default auth type for various integrations.
- Refactored connectionAuth.js to include a function for checking the new auth type.
- Adjusted PlatformAuthorization to manage the new auth type logic.
- Updated the API utility function `checkPlatform` to `verifyPluginActivation`.
- Refactored all integration components to use `pluginCheck` instead of `platformCheck` for plugin verification.
- Introduced a new `PluginCheck` class in the backend to handle plugin availability checks with improved logic and structure.
- Replaced instances of PlatformAuthorization with Authorization in MailMint, MailPoet, MailerPress, Mailster, MasterStudyLms, Memberpress, Newsletter, NotificationX, PaidMembershipPro, PeepSo, PropovoiceCRM, RestrictContent, SliceWp, SureMembers, SystemeIO, TeamsForWooCommerceMemberships, TheEventsCalendar, TutorLms, UltimateAffiliatePro, UserRegistrationMembership, Voxel, WCAffiliate, WPCafe, WPCourseware, WPForo, WeDocs, WishlistMember, WooCommerce, and WpErp components.
- Deleted the old PlatformAuthorization component and created a new Authorization component that consolidates the functionality.
…nt and enhance Fabman integration with new account fetching logic
… integrations to use a unified Authorization component and remove deprecated authorization methods
…ove authorization handling and channel fetching

- Updated Slack integration to use toast notifications for error handling and channel fetching.
- Refactored SmartSuite integration to streamline authentication and solution fetching processes.
- Simplified Vbout integration by removing unnecessary state management and using a more modular approach for authorization.
- Enhanced WhatsApp integration to utilize a centralized Authorization component for better code organization and maintainability.
- Improved header template resolution in AddNewConnection component to dynamically handle additional headers based on provided data.
…ts to use a unified Authorization component; streamline authentication logic and improve code maintainability. Update API request handling to support dynamic payloads and headers. Enhance validation for required fields in API connections.
…rization component

- Updated ActiveCampaign, Asana, Bento, CapsuleCRM, and MoxieCRM authorization components to utilize a new Authorization component for handling authentication.
- Simplified state management and input handling by removing redundant code.
- Introduced a consistent structure for authorization details, including API endpoints and authentication methods.
- Improved user instructions for obtaining API keys and tokens across various integrations.
…ied authorization handling for Clickup, Demio, and SuiteDash integrations
…ConvertKit integrations; streamline API request logic and enhance code maintainability
RishadAlam added 14 commits May 13, 2026 11:42
…nent for Dropbox, Google Contacts, Google Sheets, and OneDrive; streamline authentication handling and improve code maintainability.
- Removed unused imports and code related to token handling in Constant Contact and LionDesk components.
- Simplified the authorization process by integrating a common Authorization component for both Constant Contact and LionDesk.
- Updated the handling of API requests to use a unified method for building authentication parameters.
- Improved user instructions and error handling in the authorization steps for both integrations.
- Cleaned up the codebase by removing deprecated functions and unnecessary state management.
…emove unused functions

- Removed setGrantTokenResponse function from ZohoMarketingHub, ZohoRecruit, and ZohoSheet components.
- Simplified authorization handling in ZohoMarketingHubAuthorization, ZohoRecruitAuthorization, and ZohoSheetAuthorization components by integrating a common Authorization component.
- Updated refreshLists and refreshModules functions to utilize a buildAuthRequestParams helper for cleaner parameter handling.
- Removed unnecessary state management and error handling related to client ID and secret in authorization components.
- Enhanced user experience by ensuring proper loading states and error messages during authorization.
Copilot AI review requested due to automatic review settings May 15, 2026 09:55
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 15, 2026

🔍 WordPress Plugin Check Report

❌ Status: Failed

📊 Report

🎯 Total Issues ❌ Errors ⚠️ Warnings
2 1 1

❌ Errors (1)

📁 backend/Actions/WpDataTables/RecordApiHelper.php (1 error)
📍 Line 🔖 Check 💬 Message
37 WordPress.WP.I18n.MissingTranslatorsComment A function call to __() with texts containing placeholders was found, but was not accompanied by a "translators:" comment on the line above to clarify the meaning of the placeholders.

⚠️ Warnings (1)

📁 readme.txt (1 warning)
📍 Line 🔖 Check 💬 Message
0 mismatched_plugin_name Plugin name "Bit integrations - Form Integration, Webhook, Spreadsheets, CRM, LMS & Email Automation" is different from the name declared in plugin header "Bit Integrations".

🤖 Generated by WordPress Plugin Check Action • Learn more about Plugin Check

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request standardizes the authorization mechanism across numerous integration controllers by introducing a static $authConfig property and removing redundant authentication methods and routes. The refactor also includes unified token normalization and expiry logic for OAuth2-based services. Feedback identifies a potential PHP 8.0+ warning in GoogleSheetController due to unsafe property access on boolean values, recommends removing dead code in the Fabman integration, and highlights a performance bottleneck in MailChimpController caused by repeated network requests for metadata during the execution flow.

Comment thread backend/Actions/GoogleSheet/GoogleSheetController.php Outdated
Comment thread backend/Actions/Fabman/RecordApiHelper.php Outdated
Comment thread backend/Actions/MailChimp/MailChimpController.php
Copilot AI review requested due to automatic review settings May 15, 2026 10:08
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

Copilot AI review requested due to automatic review settings May 15, 2026 10:41
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

Copilot AI review requested due to automatic review settings May 25, 2026 04:18
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot wasn't able to review this pull request because it exceeds the maximum number of files (300). Try reducing the number of changed files and requesting a review from Copilot again.

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