Skip to content

chore: Detailed connection checks for Virtru PDP#40013

Merged
KevLehman merged 8 commits intofeat/externalpdpfrom
fix/healthcheck
Apr 1, 2026
Merged

chore: Detailed connection checks for Virtru PDP#40013
KevLehman merged 8 commits intofeat/externalpdpfrom
fix/healthcheck

Conversation

@KevLehman
Copy link
Copy Markdown
Member

@KevLehman KevLehman commented Mar 31, 2026

Proposed changes (including videos or screenshots)

Issue(s)

https://rocketchat.atlassian.net/browse/CORE-2037

Steps to test or reproduce

Further comments

AIM: users should know exactly why the connection fails when setting up virtru. For this, we're gonna test the flow we actually use: Get token, then contact virtru with the token.

A dedicated healthz test for virtru is added so we know if the platform is just not available.

Summary by CodeRabbit

Release Notes

  • New Features
    • Added a "Test Connection" button in ABAC Virtru settings to verify Policy Decision Point connectivity and health status.
    • Enhanced health check endpoint with rate limiting (5 requests per 60 seconds) and improved error messaging for platform, IdP, and authorization failures.

@dionisio-bot
Copy link
Copy Markdown
Contributor

dionisio-bot bot commented Mar 31, 2026

Looks like this PR is not ready to merge, because of the following issues:

  • This PR is missing the 'stat: QA assured' label
  • This PR is missing the required milestone or project

Please fix the issues and try again

If you have any trouble, please check the PR guidelines

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 31, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 6bad4510-af22-4d69-88d4-2a45759c6690

📥 Commits

Reviewing files that changed from the base of the PR and between 7d82278 and 445c281.

📒 Files selected for processing (11)
  • apps/meteor/client/views/admin/ABAC/ABACSettingTab/SettingsPage.tsx
  • apps/meteor/ee/server/api/abac/index.ts
  • apps/meteor/ee/server/api/abac/schemas.ts
  • apps/meteor/ee/server/settings/abac.ts
  • ee/packages/abac/src/index.ts
  • ee/packages/abac/src/pdp/LocalPDP.ts
  • ee/packages/abac/src/pdp/VirtruPDP.ts
  • ee/packages/abac/src/pdp/types.ts
  • packages/core-services/src/types/IAbacService.ts
  • packages/core-typings/src/ISetting.ts
  • packages/i18n/src/locales/en.i18n.json

Walkthrough

This pull request introduces a health check endpoint for the ABAC Virtru Policy Decision Point (PDP). It adds a new GET /abac/pdp/health API endpoint with rate limiting, implements health check logic across PDP implementations (platform connectivity, IdP token generation, authorization checks for Virtru), updates related schemas and interfaces, registers a settings action to test the connection, and includes corresponding UI and i18n updates.

Changes

Cohort / File(s) Summary
ABAC Health Check API
apps/meteor/ee/server/api/abac/index.ts
Enhanced GET /abac/pdp/health endpoint with 5 req/60s rate limiting, replaced isPdpAvailable() with getPDPHealth(), added error response schema mapping, and structured responses to include message field and available status.
API Schemas
apps/meteor/ee/server/api/abac/schemas.ts
Updated GETAbacPdpHealthResponseSchema to require message field and disallow unknown properties; added new GETAbacPdpHealthErrorResponseSchema for error responses with fixed success: false and available: false.
Settings & UI
apps/meteor/ee/server/settings/abac.ts, apps/meteor/client/views/admin/ABAC/ABACSettingTab/SettingsPage.tsx
Registered new ABAC_Virtru_Test_Connection action setting targeting the health check endpoint; added corresponding SettingField in the UI accordion section.
PDP Health Check Implementation
ee/packages/abac/src/index.ts, ee/packages/abac/src/pdp/LocalPDP.ts, ee/packages/abac/src/pdp/VirtruPDP.ts
Replaced isPdpAvailable(): Promise<boolean> with getPDPHealth(): Promise<void> in AbacService; LocalPDP returns void; VirtruPDP implements three sequential health checks (platform /healthz, IdP token generation, authorization via GetDecisions) with stage-specific error messages.
Interface & Type Definitions
ee/packages/abac/src/pdp/types.ts, packages/core-services/src/types/IAbacService.ts, packages/core-typings/src/ISetting.ts
Updated IPolicyDecisionPoint and IAbacService to expose getHealthStatus()/getPDPHealth() methods; extended SettingValue union to support endpoint objects with `{ method: 'GET'
Internationalization
packages/i18n/src/locales/en.i18n.json
Added 7 new translation keys: ABAC_PDP_Health_OK, ABAC_PDP_Health_No_PDP, ABAC_PDP_Health_IdP_Failed, ABAC_PDP_Health_Platform_Failed, ABAC_PDP_Health_Authorization_Failed, ABAC_Virtru_Test_Connection, ABAC_Virtru_Test_Connection_Action.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client (Admin UI)
    participant Server as API Server
    participant AbacService as ABAC Service
    participant PDP as PDP Instance<br/>(Local or Virtru)
    
    Client->>Server: GET /abac/pdp/health
    Server->>AbacService: getPDPHealth()
    alt PDP configured
        AbacService->>PDP: getHealthStatus()
        alt Local PDP
            PDP->>PDP: Return immediately<br/>(always available)
        else Virtru PDP
            PDP->>PDP: Check platform /healthz
            PDP->>PDP: Verify IdP token generation
            PDP->>PDP: Test authorization via GetDecisions
        end
        PDP-->>AbacService: Success or throw error
        AbacService-->>Server: Resolved or rejected
    else No PDP configured
        AbacService-->>Server: Throw ABAC_PDP_Health_No_PDP
    end
    alt Success
        Server-->>Client: { success: true, available: true,<br/>message: 'ABAC_PDP_Health_OK' }
    else Failure
        Server-->>Client: { success: false, available: false,<br/>message: error message }
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Suggested labels

type: feature, area: authentication


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@changeset-bot
Copy link
Copy Markdown

changeset-bot bot commented Mar 31, 2026

⚠️ No Changeset found

Latest commit: 445c281

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Copy Markdown
Contributor

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.

Pull request overview

This PR improves ABAC Virtru PDP setup diagnostics by replacing a simple “available/unavailable” check with a more detailed health check flow (token acquisition + Virtru platform reachability + authenticated request), and exposes that via the REST API with i18n-friendly status keys.

Changes:

  • Replace isPdpAvailable(): Promise<boolean> with getPdpHealth(): Promise<void> across the ABAC service and PDP interfaces.
  • Add Virtru PDP getHealthStatus() that checks /healthz and performs an authenticated request using an OIDC client token.
  • Update the /abac/pdp/health endpoint to return a success payload with a translated message key and add rate limiting.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/i18n/src/locales/en.i18n.json Adds new ABAC PDP health i18n keys/messages.
packages/core-services/src/types/IAbacService.ts Replaces boolean availability API with getPdpHealth() void API.
ee/packages/abac/src/pdp/VirtruPDP.ts Implements detailed Virtru PDP health checks (token, /healthz, authenticated request).
ee/packages/abac/src/pdp/types.ts Extends IPolicyDecisionPoint with getHealthStatus().
ee/packages/abac/src/pdp/LocalPDP.ts Adds a no-op getHealthStatus() for the local PDP.
ee/packages/abac/src/index.ts Implements AbacService.getPdpHealth() and updates service behavior accordingly.
apps/meteor/ee/server/api/abac/schemas.ts Updates REST response schemas for the PDP health endpoint.
apps/meteor/ee/server/api/abac/index.ts Updates /abac/pdp/health handler (messages + rate limiting + new error schema).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 31, 2026

Codecov Report

❌ Patch coverage is 10.34483% with 26 lines in your changes missing coverage. Please review.
✅ Project coverage is 70.37%. Comparing base (7d82278) to head (445c281).
⚠️ Report is 1 commits behind head on feat/externalpdp.

Additional details and impacted files

Impacted file tree graph

@@                 Coverage Diff                  @@
##           feat/externalpdp   #40013      +/-   ##
====================================================
- Coverage             70.37%   70.37%   -0.01%     
====================================================
  Files                  3270     3270              
  Lines                117050   117076      +26     
  Branches              21151    21165      +14     
====================================================
+ Hits                  82376    82392      +16     
- Misses                32604    32614      +10     
  Partials               2070     2070              
Flag Coverage Δ
e2e 60.49% <ø> (+0.04%) ⬆️
e2e-api 48.14% <ø> (+0.07%) ⬆️
unit 70.74% <10.34%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

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.

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@KevLehman KevLehman marked this pull request as ready for review April 1, 2026 19:37
@KevLehman KevLehman requested review from a team as code owners April 1, 2026 19:37
@KevLehman KevLehman merged commit e339562 into feat/externalpdp Apr 1, 2026
45 checks passed
@KevLehman KevLehman deleted the fix/healthcheck branch April 1, 2026 19:37
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 11 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="apps/meteor/ee/server/api/abac/index.ts">

<violation number="1" location="apps/meteor/ee/server/api/abac/index.ts:383">
P2: Guard the catch value before reading `.message`; the `as Error` cast hides non-Error cases and can return an undefined/incorrect message.

(Based on your team's feedback about avoiding unsafe type casts.) [FEEDBACK_USED]</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

await Abac.getPDPHealth();
return API.v1.success({ available: true, message: 'ABAC_PDP_Health_OK' });
} catch (err) {
return API.v1.failure({ available: false, message: (err as Error).message });
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai bot Apr 1, 2026

Choose a reason for hiding this comment

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

P2: Guard the catch value before reading .message; the as Error cast hides non-Error cases and can return an undefined/incorrect message.

(Based on your team's feedback about avoiding unsafe type casts.)

View Feedback

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/meteor/ee/server/api/abac/index.ts, line 383:

<comment>Guard the catch value before reading `.message`; the `as Error` cast hides non-Error cases and can return an undefined/incorrect message.

(Based on your team's feedback about avoiding unsafe type casts.) </comment>

<file context>
@@ -363,15 +364,24 @@ const abacEndpoints = API.v1
+				await Abac.getPDPHealth();
+				return API.v1.success({ available: true, message: 'ABAC_PDP_Health_OK' });
+			} catch (err) {
+				return API.v1.failure({ available: false, message: (err as Error).message });
+			}
 		},
</file context>
Suggested change
return API.v1.failure({ available: false, message: (err as Error).message });
const message = err instanceof Error ? err.message : 'ABAC_PDP_Health_Error';
return API.v1.failure({ available: false, message });
Fix with Cubic

@coderabbitai coderabbitai bot added type: feature Pull requests that introduces new feature area: authentication labels Apr 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: authentication type: feature Pull requests that introduces new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants