Skip to content

Mcp oauth - #25391

Merged
Vishnuujain merged 100 commits into
mainfrom
mcp-oauth
Mar 19, 2026
Merged

Mcp oauth#25391
Vishnuujain merged 100 commits into
mainfrom
mcp-oauth

Conversation

@Vishnuujain

@Vishnuujain Vishnuujain commented Jan 19, 2026 •

Copy link
Copy Markdown
Contributor

Describe your changes:

MCP OAuth Implementation

This PR implements OAuth 2.0 Authorization Code Flow with PKCE for MCP integration.

Key Features

  • OAuth 2.0 with PKCE (RFC 7636)
  • Google SSO + Basic Auth support
  • Refresh token rotation
  • Comprehensive audit logging

📖 Full Documentation →

Fixes

I worked on ... because ...



Summary by Gitar

  • Security hardening:
    • XFF rate-limit bypass fix with IP format validation and map size capping
    • Bcrypt secret storage with atomic CAS rotation
    • ID token validation and null safety for PKCE/grant_type/refresh_token
  • Bug fixes:
    • Fixed MCP OAuth SSO callback for Okta with redirect_uri and pac4j session attributes
    • Fixed missing return in MCP callback error path
    • Registration metadata length validation and loopback host check
  • Infrastructure:
    • Database migrations (1.12.3) with oauth_audit_log table removal
    • OAuth token cleanup job and scheduler
    • Configuration schema and TypeScript type definitions added

This will update automatically on new commits.

@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

1 similar comment
@github-actions

Copy link
Copy Markdown
Contributor

Hi there 👋 Thanks for your contribution!

The OpenMetadata team will review the PR shortly! Once it has been labeled as safe to test, the CI workflows
will start executing and we'll be able to make sure everything is working as expected.

Let us know if you need any help!

@Vishnuujain Vishnuujain added the safe to test Add this label to run secure Github workflows on PRs label Jan 19, 2026
@Vishnuujain
Vishnuujain force-pushed the mcp-oauth branch 7 times, most recently from a15e981 to e253233 Compare January 20, 2026 06:52
@gitar-bot

gitar-bot Bot commented Mar 12, 2026

Copy link
Copy Markdown

@gitar-bot can you check again the issues flagged, most of them already have comments or fixes in place so you can ignore those

Re-checked all flagged issues. Here's the updated status:

✅ Fixed / Dismissed

Finding Status
client_secret_basic accepted but non-functional Fixed in commit 833d9839 — only client_secret_post and none are now accepted
MySQL CREATE INDEX idempotency Fixed in 833d9839 — all indexes are now inline within CREATE TABLE IF NOT EXISTS
Token auto-deleted on Fernet decryption failure Fixed in 833d9839 — now logs and returns null instead of deleting
Glue script parser regexes Dismissed — not part of this PR
Unauthenticated dynamic client registration Dismissed — acknowledged as intentional design

Still Open

Finding Notes
Refresh token rotation not wrapped in a transaction (rotateRefreshToken in OAuthTokenRepository.java:166) revokeAtomic + revokeAllForUser + insert are still three separate DB calls with no transaction boundary. A crash between steps leaves the user with all tokens revoked and no recovery path.
client_secret_encrypted column stores BCrypt hashes (minor) Naming implies reversible encryption; consider client_secret_hash or updating the column comment.
Postgres tables lack updated_at tracking (minor) oauth_authorization_codes.used and oauth_refresh_tokens.revoked are updated in-place with no timestamp tracking.

The transaction issue is the only remaining substantive concern — the other two are minor naming/schema quality items.

@github-actions

Copy link
Copy Markdown
Contributor

✅ TypeScript Types Auto-Updated

The generated TypeScript types have been automatically updated based on JSON schema changes in this PR.

@github-actions

github-actions Bot commented Mar 13, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Playwright Results — all passed (18 flaky)

✅ 3386 passed · ❌ 0 failed · 🟡 18 flaky · ⏭️ 183 skipped

Shard Passed Failed Flaky Skipped
🟡 Shard 1 452 0 3 2
🟡 Shard 2 303 0 2 1
🟡 Shard 3 668 0 5 33
🟡 Shard 4 684 0 1 41
🟡 Shard 5 671 0 1 73
🟡 Shard 6 608 0 6 33
🟡 18 flaky test(s) (passed on retry)
  • Features/CustomizeDetailPage.spec.ts › Data Product - customization should work (shard 1, 1 retry)
  • Features/CustomizeDetailPage.spec.ts › Glossary Term - customization should work (shard 1, 1 retry)
  • Features/MetricCustomUnitFlow.spec.ts › Should create metric and test unit of measurement updates (shard 1, 1 retry)
  • Features/AutoPilot.spec.ts › Agents created by AutoPilot should be deleted (shard 2, 1 retry)
  • Pages/DataContracts.spec.ts › Add and update Security and SLA tabs (shard 2, 1 retry)
  • Features/DataQuality/TestCaseIncidentPermissions.spec.ts › User with TEST_CASE.EDIT_ALL can see edit icon on incidents (shard 3, 1 retry)
  • Features/DataQuality/TestCaseResultPermissions.spec.ts › User with only VIEW cannot PATCH results (shard 3, 1 retry)
  • Features/Glossary/GlossaryP3Tests.spec.ts › should handle special characters in search (shard 3, 1 retry)
  • Features/ImpactAnalysis.spec.ts › Verify column level upstream connections (shard 3, 1 retry)
  • Features/Permissions/GlossaryPermissions.spec.ts › Team-based permissions work correctly (shard 3, 1 retry)
  • Pages/Customproperties-part2.spec.ts › entityReferenceList shows item count, scrollable list, no expand toggle (shard 4, 1 retry)
  • Pages/Entity.spec.ts › Tier Add, Update and Remove (shard 5, 1 retry)
  • Pages/Glossary.spec.ts › Column selection and visibility for Glossary Terms table (shard 6, 1 retry)
  • Pages/Glossary.spec.ts › Column dropdown drag-and-drop functionality for Glossary Terms table (shard 6, 1 retry)
  • Pages/HyperlinkCustomProperty.spec.ts › should accept valid http and https URLs (shard 6, 1 retry)
  • Pages/InputOutputPorts.spec.ts › Add single input port (shard 6, 1 retry)
  • Pages/ODCSImportExport.spec.ts › Multi-object ODCS contract - object selector shows all schema objects (shard 6, 1 retry)
  • Pages/Users.spec.ts › Permissions for table details page for Data Consumer (shard 6, 1 retry)

📦 Download artifacts

How to debug locally
# Download playwright-test-results-<shard> artifact and unzip
npx playwright show-trace path/to/trace.zip    # view trace

Vishnuujain and others added 7 commits March 16, 2026 16:22
# Conflicts:
#	openmetadata-service/src/main/java/org/openmetadata/service/OpenMetadataApplication.java
# Conflicts:
#	openmetadata-ui/src/main/resources/ui/src/components/DataQuality/AddTestCaseList/AddTestCaseList.component.tsx
@sonarqubecloud

Copy link
Copy Markdown

) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

CREATE TABLE IF NOT EXISTS oauth_authorization_codes (
id CHAR(36) PRIMARY KEY DEFAULT (UUID()),

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.

should these be encoded with fernet for encryption?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

auth_codes were stored as plaintext because they're short-lived, single-use, and protected by PKCE. but we can add SHA-256 hashing for consistency with how access/refresh tokens are looked up. Fernet encryption isn't needed here though.

@gitar-bot

gitar-bot Bot commented Mar 18, 2026

Copy link
Copy Markdown
Code Review ⚠️ Changes requested 56 resolved / 61 findings

OAuth implementation adds client secret hashing, impersonation compatibility fixes, and resolves 34 prior security findings, but 5 open issues remain: script parser regexes miss chained calls, client_secret_encrypted column semantics misaligned with BCrypt storage, refresh token rotation lacks transaction wrapping, Postgres tables missing updated_at auto-update trigger, and TAG_USAGE constants declared in interface.

⚠️ Bug: Glue script parser regexes miss chained calls, overcapture args

The five regex patterns (FROM_OPTIONS_PATTERN, WRITE_JDBC_CONF_PATTERN, WRITE_OPTIONS_PATTERN, WRITE_CATALOG_PATTERN, PURGE_TABLE_PATTERN) in the new script_parser.py use \)\s*$ with re.DOTALL | re.MULTILINE. The $ with MULTILINE matches end-of-line, not end-of-string. When a Glue script uses chained calls (extremely common in PySpark), e.g. .from_options(...).toDF(), the lazy (.*?) expands to include .toDF( in the captured group, corrupting the extracted arguments. This causes _extract_kwarg / _extract_dict_value to produce wrong or null results, silently dropping lineage edges.

FROM_CATALOG_PATTERN uses only re.DOTALL without $ anchoring and works correctly.

Fix: Remove the \s*$ anchor and re.MULTILINE flag from all five patterns, matching FROM_CATALOG_PATTERN's style.

Suggested fix
# Remove \s*$ anchor and re.MULTILINE from all five patterns.
# Example fix for FROM_OPTIONS_PATTERN:
FROM_OPTIONS_PATTERN = re.compile(
    r"create_dynamic_frame\.from_options\s*\((.*?)\)",
    re.DOTALL,
)
# Apply same to WRITE_JDBC_CONF_PATTERN,
# WRITE_OPTIONS_PATTERN, WRITE_CATALOG_PATTERN,
# PURGE_TABLE_PATTERN
⚠️ Bug: Refresh token rotation not wrapped in a transaction

📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/repository/OAuthTokenRepository.java:192 📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/repository/OAuthTokenRepository.java:195 📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/repository/OAuthTokenRepository.java:203 📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/repository/OAuthTokenRepository.java:208

In OAuthTokenRepository.rotateRefreshToken(), three sequential DB operations — (1) revokeAtomic(oldTokenHash), (2) revokeAllForUser(clientId, userName), (3) refreshTokenDAO.insert(...) — are not wrapped in a database transaction. If the process crashes or an exception occurs between steps 1 and 3, the old token is revoked but no new token is issued, leaving the user with all refresh tokens revoked and no way to recover without re-authenticating. This also creates a brief window where a concurrent request could observe a partially-rotated state.

Suggested fix
Wrap all three operations in a JDBI transaction:

public void rotateRefreshToken(...) {
  String oldTokenHash = hashToken(oldTokenValue);
  String tokenHash = hashToken(newToken.getToken());
  String encryptedToken = fernet.encrypt(newToken.getToken());

  // Use JDBI's useTransaction to make all three ops atomic
  handle.useTransaction(h -> {
    int rows = refreshTokenDAO.revokeAtomic(oldTokenHash);
    if (rows == 0) throw new TokenRotationException("...");
    refreshTokenDAO.revokeAllForUser(clientId, userName);
    refreshTokenDAO.insert(tokenHash, encryptedToken, ...);
  });
}
💡 Quality: Column client_secret_encrypted now stores BCrypt hashes

📄 bootstrap/sql/migrations/native/1.12.2/postgres/schemaChanges.sql:58 📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/repository/OAuthClientRepository.java:34

The column client_secret_encrypted and its SQL comment ('Encrypted client secret') imply reversible encryption, but the code now stores BCrypt hashes (one-way). This naming mismatch will confuse future developers and DBAs inspecting the schema. Consider renaming to client_secret_hash or at minimum updating the column comment.

💡 Bug: Postgres tables lack updated_at auto-update trigger

📄 bootstrap/sql/migrations/native/1.12.3/postgres/schemaChanges.sql:12 📄 bootstrap/sql/migrations/native/1.12.3/mysql/schemaChanges.sql:12

The MySQL tables use TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP for created_at, which MySQL auto-updates on row modification. The Postgres tables use TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP for created_at but Postgres does NOT auto-update timestamps. Neither migration defines an updated_at column or trigger. While these OAuth tables may not need update tracking (tokens are typically insert-then-revoke), the oauth_authorization_codes.used column and oauth_refresh_tokens.revoked column are updated in-place without any timestamp tracking of when they were modified.

💡 Quality: TAG_USAGE_LOG and TAG_USAGE_MAX_ATTEMPTS are interface constants

📄 openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java:5404

In TagUsageDAO (an interface within CollectionDAO), TAG_USAGE_LOG, TAG_USAGE_MAX_ATTEMPTS, and TAG_USAGE_DEADLOCK_RETRY_COUNT are declared as interface fields, making them implicitly public static final. While this works for Logger and AtomicLong (whose internal state is mutable), TAG_USAGE_MAX_ATTEMPTS as int is fine. However, the AtomicLong TAG_USAGE_DEADLOCK_RETRY_COUNT is shared globally as an interface constant — which is the intent for a global counter but may be surprising. Consider adding a comment clarifying the intentional global sharing of the mutable counter.

✅ 56 resolved
✅ Security: Token endpoint lacks client authentication for confidential clients

📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/transport/OAuthHttpStatelessServerTransportProvider.java:489 📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/middleware/ClientAuthenticator.java:26 🔗 RFC 6749: Client Authentication at Token Endpoint
The handleTokenRequest method in OAuthHttpStatelessServerTransportProvider (line 489) extracts client_id from request parameters and uses it directly to look up the client, but never validates the client_secret before issuing tokens. The ClientAuthenticator class exists (line 67) and has proper constant-time secret comparison, but it is never invoked in the token exchange flow.

Specifically:

  • Line 519: authProvider.getClient(clientId).join() — loads client by ID only
  • Line 552: authProvider.exchangeAuthorizationCode(client, authCode).join() — exchanges code without authenticating the client
  • Line 556-571: Same issue for refresh token exchange

This means that if an attacker learns a valid client_id (which is a UUID, not a secret), they can exchange authorization codes and refresh tokens without knowing the client_secret. While PKCE protects the authorization code exchange, the refresh token exchange has no such protection — an attacker who intercepts a refresh token can use it with just the client_id.

Recommendation: Call clientAuthenticator.authenticate(clientId, clientSecret) in handleTokenRequest for both authorization_code and refresh_token grant types before proceeding with the exchange.

✅ Bug: Session regeneration drops attributes, breaking Basic Auth flow

📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/provider/UserSSOOAuthProvider.java:543 📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/provider/UserSSOOAuthProvider.java:585 📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/provider/UserSSOOAuthProvider.java:644
The handleBasicAuthLogin method reads session attributes (SESSION_MCP_PKCE_CHALLENGE, SESSION_MCP_REDIRECT_URI, etc.) on line 539-541 and then calls regenerateSession(session) on line 543, which may invalidate the session entirely (see the fallback path on line 664 where oldSession.invalidate() is called).

However, the code reads codeChallenge, redirectUri, and scopesStr before regenerating, so the values are captured. The issue is that after regenerateSession, on line 560, the code calls displayAuthorizationCode(authCode, currentRequest.get().getSession(false)), which tries to read SESSION_MCP_REDIRECT_URI and SESSION_MCP_STATE from the new session (line 588-589).

Since regenerateSession explicitly does NOT preserve session attributes (per the method's own Javadoc on lines 634-636: "This method does NOT preserve old session attributes"), the new session will have null for SESSION_MCP_REDIRECT_URI and SESSION_MCP_STATE, causing displayAuthorizationCode to throw on line 592 ("Redirect URI not found in session").

This means the entire Basic Auth login flow will fail with "server_error" when the servlet container falls back to invalidate/recreate session regeneration.

Recommendation: Pass redirectUri and state as direct method parameters to displayAuthorizationCode instead of reading them from the regenerated session.

✅ Security: Overly broad endsWith() path matching in auth filter bypass

📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/McpAuthFilter.java:108 📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/OAuthWellKnownFilter.java:32
The McpAuthFilter.isOAuthEndpoint() method uses path.endsWith() for matching OAuth paths that should bypass authentication. While the current servlet routing setup means McpAuthFilter is reportedly NOT registered for /mcp/* (per comment in McpServer.java line 137), looking at the actual code in McpAuthFilter.doFilter() line 42, it's still checking ApplicationContext for the McpApplication before the OAuth endpoint check. If this filter IS applied to any broader path pattern now or in the future, the endsWith() matching is dangerously broad.

For example, path.endsWith("/token") would match any path ending in /token, not just the OAuth token endpoint. An attacker could craft /api/v1/mcp/some-mcp-tool/token to bypass auth.

More concretely, the OAuthWellKnownFilter.java is registered on "/*" (root level) and uses exact path.equals() checks, which is the correct approach. The McpAuthFilter should follow the same pattern.

Additionally, path.endsWith("/register") allows unauthenticated access to any path ending in /register, which could inadvertently exempt future endpoints.

Recommendation: Use exact path matching instead of endsWith(). For example, check path.equals("/api/v1/mcp/register") or match against a prefix like path.startsWith("/api/v1/mcp/") && path.endsWith("/token").

✅ Bug: Duplicate McpApplication install check in auth filter

📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/McpAuthFilter.java:42 📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/McpAuthFilter.java:68
McpAuthFilter.doFilter() checks if McpApplication is installed twice — once at line 42 (before OAuth endpoint bypass) and again at line 68 (after). The second check is dead code since the first check already returns early if the app is not installed, blocking ALL requests including legitimate OAuth endpoint requests.

This means if McpApplication is not installed, OAuth discovery endpoints (.well-known) will also be blocked, which is fine from a security perspective, but the duplicate check is confusing.

Recommendation: Remove the duplicate check at line 68. The first check at line 42 is sufficient.

✅ Security: Transport provider still uses endsWith() for OAuth route matching

📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/transport/OAuthHttpStatelessServerTransportProvider.java:259 📄 openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/transport/OAuthHttpStatelessServerTransportProvider.java:371
The OAuthHttpStatelessServerTransportProvider routes OAuth requests using path.endsWith() in both doGet() (lines 259, 261, 263) and doPost() (lines 371, 373, 375, 377). While the auth filter (McpAuthFilter) was correctly fixed to use path.equals(), the transport provider's endsWith() matching means a crafted request path like /evil/mcp/token or /admin/../mcp/token could potentially match the token endpoint handler if the servlet container normalizes paths unexpectedly.

Since this servlet is mounted at /mcp, the path variable from request.getRequestURI() should normally include the /mcp prefix. However, relying on endsWith() is fragile — if the servlet mapping changes or if path normalization differs across containers, this could route unexpected paths to sensitive OAuth endpoints.

Impact: Potential for path confusion attacks in certain servlet container configurations, especially in environments with reverse proxies that may alter request URIs.

Suggested fix: Use exact path matching (path.equals("/mcp/token")) or strip the known prefix and compare (path.equals(servletPath + "/token")), consistent with how McpAuthFilter was fixed.

...and 51 more resolved from earlier reviews

🤖 Prompt for agents
Code Review: OAuth implementation adds client secret hashing, impersonation compatibility fixes, and resolves 34 prior security findings, but 5 open issues remain: script parser regexes miss chained calls, client_secret_encrypted column semantics misaligned with BCrypt storage, refresh token rotation lacks transaction wrapping, Postgres tables missing updated_at auto-update trigger, and TAG_USAGE constants declared in interface.

1. ⚠️ Bug: Glue script parser regexes miss chained calls, overcapture args

   The five regex patterns (FROM_OPTIONS_PATTERN, WRITE_JDBC_CONF_PATTERN, WRITE_OPTIONS_PATTERN, WRITE_CATALOG_PATTERN, PURGE_TABLE_PATTERN) in the new script_parser.py use `\)\s*$` with `re.DOTALL | re.MULTILINE`. The `$` with MULTILINE matches end-of-line, not end-of-string. When a Glue script uses chained calls (extremely common in PySpark), e.g. `.from_options(...).toDF()`, the lazy `(.*?)` expands to include `.toDF(` in the captured group, corrupting the extracted arguments. This causes `_extract_kwarg` / `_extract_dict_value` to produce wrong or null results, silently dropping lineage edges.
   
   FROM_CATALOG_PATTERN uses only `re.DOTALL` without `$` anchoring and works correctly.
   
   Fix: Remove the `\s*$` anchor and `re.MULTILINE` flag from all five patterns, matching FROM_CATALOG_PATTERN's style.

   Suggested fix:
   # Remove \s*$ anchor and re.MULTILINE from all five patterns.
   # Example fix for FROM_OPTIONS_PATTERN:
   FROM_OPTIONS_PATTERN = re.compile(
       r"create_dynamic_frame\.from_options\s*\((.*?)\)",
       re.DOTALL,
   )
   # Apply same to WRITE_JDBC_CONF_PATTERN,
   # WRITE_OPTIONS_PATTERN, WRITE_CATALOG_PATTERN,
   # PURGE_TABLE_PATTERN

2. 💡 Quality: Column `client_secret_encrypted` now stores BCrypt hashes
   Files: bootstrap/sql/migrations/native/1.12.2/postgres/schemaChanges.sql:58, openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/repository/OAuthClientRepository.java:34

   The column `client_secret_encrypted` and its SQL comment ('Encrypted client secret') imply reversible encryption, but the code now stores BCrypt hashes (one-way). This naming mismatch will confuse future developers and DBAs inspecting the schema. Consider renaming to `client_secret_hash` or at minimum updating the column comment.

3. ⚠️ Bug: Refresh token rotation not wrapped in a transaction
   Files: openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/repository/OAuthTokenRepository.java:192, openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/repository/OAuthTokenRepository.java:195, openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/repository/OAuthTokenRepository.java:203, openmetadata-mcp/src/main/java/org/openmetadata/mcp/server/auth/repository/OAuthTokenRepository.java:208

   In `OAuthTokenRepository.rotateRefreshToken()`, three sequential DB operations — (1) `revokeAtomic(oldTokenHash)`, (2) `revokeAllForUser(clientId, userName)`, (3) `refreshTokenDAO.insert(...)` — are not wrapped in a database transaction. If the process crashes or an exception occurs between steps 1 and 3, the old token is revoked but no new token is issued, leaving the user with all refresh tokens revoked and no way to recover without re-authenticating. This also creates a brief window where a concurrent request could observe a partially-rotated state.

   Suggested fix:
   Wrap all three operations in a JDBI transaction:
   
   public void rotateRefreshToken(...) {
     String oldTokenHash = hashToken(oldTokenValue);
     String tokenHash = hashToken(newToken.getToken());
     String encryptedToken = fernet.encrypt(newToken.getToken());
   
     // Use JDBI's useTransaction to make all three ops atomic
     handle.useTransaction(h -> {
       int rows = refreshTokenDAO.revokeAtomic(oldTokenHash);
       if (rows == 0) throw new TokenRotationException("...");
       refreshTokenDAO.revokeAllForUser(clientId, userName);
       refreshTokenDAO.insert(tokenHash, encryptedToken, ...);
     });
   }

4. 💡 Bug: Postgres tables lack updated_at auto-update trigger
   Files: bootstrap/sql/migrations/native/1.12.3/postgres/schemaChanges.sql:12, bootstrap/sql/migrations/native/1.12.3/mysql/schemaChanges.sql:12

   The MySQL tables use `TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP` for `created_at`, which MySQL auto-updates on row modification. The Postgres tables use `TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP` for `created_at` but Postgres does NOT auto-update timestamps. Neither migration defines an `updated_at` column or trigger. While these OAuth tables may not need update tracking (tokens are typically insert-then-revoke), the `oauth_authorization_codes.used` column and `oauth_refresh_tokens.revoked` column are updated in-place without any timestamp tracking of when they were modified.

5. 💡 Quality: TAG_USAGE_LOG and TAG_USAGE_MAX_ATTEMPTS are interface constants
   Files: openmetadata-service/src/main/java/org/openmetadata/service/jdbi3/CollectionDAO.java:5404

   In `TagUsageDAO` (an interface within `CollectionDAO`), `TAG_USAGE_LOG`, `TAG_USAGE_MAX_ATTEMPTS`, and `TAG_USAGE_DEADLOCK_RETRY_COUNT` are declared as interface fields, making them implicitly `public static final`. While this works for `Logger` and `AtomicLong` (whose internal state is mutable), `TAG_USAGE_MAX_ATTEMPTS` as `int` is fine. However, the `AtomicLong TAG_USAGE_DEADLOCK_RETRY_COUNT` is shared globally as an interface constant — which is the intent for a global counter but may be surprising. Consider adding a comment clarifying the intentional global sharing of the mutable counter.

Rules 🎸 1 action taken

Gitar Rules

🎸 Flaky Test Retry: Retried the 'Integration Tests - PostgreSQL + OpenSearch' run (22902857293) which failed with 3 ConditionTimeout errors waiting for entities in search index — a classic flaky timing/infrastructure pattern unrelated to the MCP OAuth code changes.

1 rule not applicable. Show all rules by commenting gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing less information.

Comment with these commands to change:

Auto-apply Compact
gitar auto-apply:on         
gitar display:verbose         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqubecloud

Copy link
Copy Markdown

This branch was previously deployed

1 inactive deployment
test — 8862fb40 Deployed Mar 19, 2026 by Vishnuujain via playwright-ci-postgresql (4, 6) #37938
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

safe to test Add this label to run secure Github workflows on PRs

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add OAuth authentication support for MCP server integration with Copilot Studio

7 participants