Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Tableau connected apps sign in with a direct trust HS256 JWT that carries a fixed scope set and lives five minutes

- **Status:** Accepted
- **Revisions:** v1 2026-11-04 (initial) · v2 2026-11-16 (the scope set adds the five write scopes of Collate's reverse metadata)
- **Deciders:** Akash Verma
- **Guard:** `ingestion/tests/unit/source/dashboard/tableau/test_connection.py`, `ingestion/tests/unit/topology/pipeline/test_tableaupipeline_connection.py`, the `connected_app` runs of `ingestion/tests/integration/tableau/` and `ingestion/tests/integration/tableaupipeline/`
- **Related:** [#33371](https://github.com/open-metadata/OpenMetadata/issues/33371)

## Context
The Tableau dashboard and pipeline connectors signed in only with a username and password or a
personal access token, both tied to one person. A Tableau connected app lets an administrator issue
credentials that sign in as a chosen user without that user's password. On Tableau Cloud 2026.3.2
(REST API 3.30) we measured the following:

- A direct trust connected app accepts only HS256 tokens signed with the app's secret value.
RS256 is rejected at sign-in with `401001`. RSA keys belong to OAuth 2.0 trust (EAS).
- Every call the two connectors make, including both Metadata API queries, returned the same result
as a PAT sign-in when the token carried `tableau:content:read`, `tableau:users:read`,
`tableau:server:read`, `tableau:flows:read`, `tableau:flow_runs:read`, `tableau:jobs:read` and
`tableau:tasks:read`. With only `tableau:content:read`, the owner, flow, flow run, job and task
calls fail with `401002 "Invalid authentication credentials were provided."`, the same answer as
bad credentials.
- Collate's reverse metadata reuses this connection to write workbook descriptions and owners
(Update Workbook, `tableau:workbooks:update`), workbook tags (`tableau:workbook_tags:update`,
`tableau:workbook_tags:delete`) and view tags (`tableau:view_tags:update`,
`tableau:view_tags:delete`). On 2026-11-16 (Tableau Cloud, REST API 3.30), each write failed with
`401002` when the token carried only the seven read scopes, and succeeded with the five added. A
token with no `scp` claim was accepted for reads and writes alike, but Tableau documents a missing
`scp` as error `10099 SCOPES_MISSING_IN_JWT`, so the claim stays.
- The session a sign-in gets outlives the token. The pipeline client's transport retries a sign-in
that Tableau answers with 429 or 5xx, re-sending the same token, which Tableau accepts only until
it expires. When Tableau ends the session, the pipeline client signs in again
(ADR:2026-10-30-tableau-pipeline-sign-in-again) with a freshly signed token.

## Decision
- A new `authType`, `TableauConnectedAppAuth` (`clientId`, `secretId`, `secretValue`, `username`),
is shared by `tableauConnection.json` and `tableauPipelineConnection.json`.
- `build_server_config` signs an HS256 JWT with the secret value: header `kid` = secret ID and
`iss` = client ID; claims `iss` = client ID, `sub` = username, `aud` = `tableau`, a new `jti` per
sign-in, `scp` = the twelve scopes above, and `exp` five minutes after signing. It passes the token
as `TSC.JWTAuth(jwt=..., site_id=...)`. `site_id` is a keyword because the second positional
parameter is `isUat`.
- The scope set and the five-minute lifetime are module constants
(`CONNECTED_APP_SCOPES`, `CONNECTED_APP_JWT_LIFETIME`), not configuration.
- A connected-app connection gets its own test-connection error pack: a 401 names the app's checks and the
scopes, and unresolved owners name `tableau:users:read`. Basic and PAT connections keep their hints.
- The supported floor is Tableau Cloud and Tableau Server 2025.3, per Tableau's REST API reference:
the connected app scopes for Query Views for Workbook (`tableau:content:read`), Query Flows for a
Site (`tableau:flows:read`) and Get Flow Runs (`tableau:flow_runs:read`) were added in API 3.27
(Tableau Cloud December 2025 / Server 2025.3). On an older Server the dashboard connector cannot
read charts and the pipeline connector cannot read flows. Server was not tested live.

## Consequences
An administrator can give OpenMetadata a credential that is not a person's password or PAT, but the
calls still run as `username`, with that user's permissions. On Tableau Cloud that is the user's
email address; on Tableau Server, the user name. Every connected-app token carries the write scopes,
read-only ingestion included; the user's site role and permissions still bound what it can change,
as they do for a PAT. The host clock must be correct, because Tableau rejects a token outside its
validity window, and Tableau Cloud caps that window at ten minutes. OAuth 2.0 trust, unified access
tokens, impersonation, per-site scopes and token refresh are not supported. Revisit the fixed scope
set if a connector starts calling an endpoint outside it, or if a site must issue tokens with fewer
scopes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,12 @@
from cachetools import LRUCache
from tableauserverclient import (
Pager,
PersonalAccessTokenAuth,
ProjectItem,
RequestOptions,
Server,
TableauAuth,
ViewItem,
)
from tableauserverclient.models import Credentials

from metadata.generated.schema.type.filterPattern import FilterPattern
from metadata.ingestion.source.dashboard.tableau.models import (
Expand Down Expand Up @@ -110,7 +109,7 @@ class TableauClient:

def __init__(
self,
tableau_server_auth: PersonalAccessTokenAuth | TableauAuth,
tableau_server_auth: Credentials,
config,
verify_ssl: bool | str,
pagination_limit: int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
from __future__ import annotations

import traceback
import uuid
from datetime import datetime, timedelta, timezone
from typing import TYPE_CHECKING

import jwt
import tableauserverclient as TSC # noqa: N812
from requests.exceptions import SSLError
from tableauserverclient.server.endpoint.exceptions import (
Expand Down Expand Up @@ -45,6 +48,9 @@
AccessTokenAuth,
)
from metadata.generated.schema.security.credentials.basicAuth import BasicAuth
from metadata.generated.schema.security.credentials.tableauConnectedAppAuth import (
TableauConnectedAppAuth,
)
from metadata.ingestion.connections.connection import BaseConnection
from metadata.ingestion.connections.test_connections import SourceConnectionException
from metadata.ingestion.source.dashboard.tableau.client import (
Expand All @@ -60,6 +66,8 @@
from metadata.utils.ssl_manager import SSLManager

if TYPE_CHECKING:
from tableauserverclient.models import Credentials

from metadata.core.connections.lifetime import Borrowed
from metadata.core.connections.test_connection import ChecksProvider
from metadata.generated.schema.entity.services.connections.pipeline.tableauPipelineConnection import (
Expand All @@ -73,6 +81,46 @@
"#enable-the-tableau-metadata-api-for-tableau-server"
)

# The calls the dashboard and pipeline connectors make, and the workbook description, owner and tag
# and view tag writes of Collate's reverse metadata, need exactly these, measured on Tableau Cloud
# (ADR:2026-11-04-tableau-connected-apps-sign-in-with-a-direct-trust-jwt).
# ponytail: fixed scope set; a site that must grant fewer needs a config field.
CONNECTED_APP_SCOPES = [
"tableau:content:read",
"tableau:users:read",
"tableau:server:read",
"tableau:flows:read",
"tableau:flow_runs:read",
"tableau:jobs:read",
"tableau:tasks:read",
"tableau:workbooks:update",
"tableau:workbook_tags:update",
"tableau:workbook_tags:delete",
"tableau:view_tags:update",
"tableau:view_tags:delete",
]
# The JWT only has to last until sign-in; the session it buys outlives it. Tableau Cloud allows 10 minutes.
CONNECTED_APP_JWT_LIFETIME = timedelta(minutes=5)
# Tableau answers a call outside the token's scopes with the same 401002 as bad credentials.
CONNECTED_APP_REJECTED = (
"Tableau rejected the connected app's token (401). Check the client ID, secret ID, secret value and "
"username, that the connected app is enabled, that the Site Name matches the site it belongs to, and "
"that the clock of the host running the ingestion is correct. "
f"A call outside the token's scopes is rejected the same way; OpenMetadata requests {', '.join(CONNECTED_APP_SCOPES)}."
)
CONNECTED_APP_METADATA_API_FLOOR = (
"Tableau documents that a connected app can use the Metadata API only on Tableau Cloud and on Tableau "
"Server 2023.3 or later; on an older Tableau Server, use a Personal Access Token."
)
OWNERS_NOT_FOUND_FIX = (
"Owners could not be resolved. Grant the user permission to read users on the site, or "
"disable owner ingestion in the service configuration."
)
DATA_MODELS_FIX = (
"The Tableau Metadata API returned no data sources for the workbook. Enable the "
"Metadata API on the Tableau instance."
)


def _status_of(error: BaseException) -> int | None:
"""Return the HTTP status a Tableau error carries, if any.
Expand Down Expand Up @@ -131,8 +179,7 @@ def _status_of(error: BaseException) -> int | None:
),
when(Matchers.exception(TableauOwnersNotFound)).diagnose(
"Owner information not available",
fix="Owners could not be resolved. Grant the user permission to read users on the site, or "
"disable owner ingestion in the service configuration.",
fix=OWNERS_NOT_FOUND_FIX,
),
when(Matchers.exception(TableauUpstreamTablesRedacted)).diagnose(
"Source table names are hidden from this account",
Expand All @@ -144,8 +191,7 @@ def _status_of(error: BaseException) -> int | None:
),
when(Matchers.exception(TableauDataModelsException)).diagnose(
"Data sources could not be read",
fix="The Tableau Metadata API returned no data sources for the workbook. Enable the "
"Metadata API on the Tableau instance.",
fix=DATA_MODELS_FIX,
doc=METADATA_API_DOC,
),
when(Matchers.contains("in incorrect format")).diagnose(
Expand All @@ -155,6 +201,21 @@ def _status_of(error: BaseException) -> int | None:
),
).including(NETWORK_ERRORS)

# A connected app has no PAT or password to check, and its token's scopes can be what Tableau refused.
TABLEAU_CONNECTED_APP_ERRORS = ErrorPack(
when(http_status(401, extract=_status_of)).diagnose("Authentication failed", fix=CONNECTED_APP_REJECTED),
# The owner lookup swallows the 401, so a token without the users scope surfaces here instead.
when(Matchers.exception(TableauOwnersNotFound)).diagnose(
"Owner information not available",
fix=f"{OWNERS_NOT_FOUND_FIX} The connected app's token also needs the tableau:users:read scope.",
),
when(Matchers.exception(TableauDataModelsException)).diagnose(
"Data sources could not be read",
fix=f"{DATA_MODELS_FIX} {CONNECTED_APP_METADATA_API_FLOOR}",
doc=METADATA_API_DOC,
),
).including(TABLEAU_ERRORS)


def get_connection(connection: TableauConnectionConfig) -> TableauClient:
"""
Expand Down Expand Up @@ -213,7 +274,7 @@ def set_verify_ssl(

def build_server_config(
connection: TableauConnectionConfig | TableauPipelineConnection,
) -> TSC.TableauAuth | TSC.PersonalAccessTokenAuth:
) -> Credentials:
"""
Build client configuration
Args:
Expand All @@ -234,6 +295,24 @@ def build_server_config(
personal_access_token=connection.authType.personalAccessTokenSecret.get_secret_value(),
site_id=connection.siteName if connection.siteName else "",
)
elif isinstance(connection.authType, TableauConnectedAppAuth):
app = connection.authType
# Direct trust accepts only HS256 tokens signed with the connected app's secret value.
token = jwt.encode(
{
"iss": app.clientId,
"sub": app.username,
"aud": "tableau",
"exp": datetime.now(timezone.utc) + CONNECTED_APP_JWT_LIFETIME,
"jti": str(uuid.uuid4()),
"scp": CONNECTED_APP_SCOPES,
},
app.secretValue.get_secret_value(),
algorithm="HS256",
headers={"kid": app.secretId, "iss": app.clientId},
)
# site_id must be a keyword: JWTAuth's second positional parameter is isUat.
tableau_auth = TSC.JWTAuth(jwt=token, site_id=connection.siteName if connection.siteName else "")
Comment thread
greptile-apps[bot] marked this conversation as resolved.
Resolved
else:
raise ValueError("Unsupported authentication type") # noqa: TRY004

Expand All @@ -247,10 +326,9 @@ class TableauChecks:
credentials or an unreachable server fail there and the rest are skipped.
"""

errors = TABLEAU_ERRORS

def __init__(self, server: Borrowed[TableauClient]) -> None:
def __init__(self, server: Borrowed[TableauClient], connected_app: bool = False) -> None:
self._server = server
self.errors = TABLEAU_CONNECTED_APP_ERRORS if connected_app else TABLEAU_ERRORS

@check(DashboardStep.ServerInfo)
def server_info(self) -> Evidence:
Expand Down Expand Up @@ -325,4 +403,7 @@ def _get_client(self) -> TableauClient:
return client

def checks(self) -> ChecksProvider:
return TableauChecks(server=self.borrow())
return TableauChecks(
server=self.borrow(),
connected_app=isinstance(self.service_connection.authType, TableauConnectedAppAuth),
)
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Key fields on `TableauPipelineConnection`:
| Field | Purpose |
|-------|---------|
| `hostPort` | Tableau Server URL |
| `authType` | `BasicAuth` (username/password) or `AccessTokenAuth` (PAT name + secret) |
| `authType` | `BasicAuth` (username/password), `AccessTokenAuth` (PAT name + secret) or `TableauConnectedAppAuth` (direct trust connected app: client ID, secret ID, secret value, username) |
| `siteName` | Tableau site (empty for default) |
| `apiVersion` | Optional REST API version override |
| `verifySSL` + `sslConfig` | TLS validation mode, CA certificate, and client certificate + key (mutual TLS) when `verifySSL=validate` |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,11 @@
from tableauserverclient import (
Filter,
Pager,
PersonalAccessTokenAuth,
RequestOptions,
Server,
Sort,
TableauAuth,
)
from tableauserverclient.models import BackgroundJobItem, FlowItem, FlowRunItem, TaskItem
from tableauserverclient.models import BackgroundJobItem, Credentials, FlowItem, FlowRunItem, TaskItem
from tableauserverclient.server.endpoint.endpoint import TABLEAU_AUTH_HEADER
from tableauserverclient.server.endpoint.exceptions import ServerResponseError
from typing_extensions import Self
Expand All @@ -44,6 +42,7 @@
from metadata.generated.schema.entity.services.connections.pipeline.tableauPipelineConnection import (
TableauPipelineConnection,
)
from metadata.ingestion.source.dashboard.tableau.connection import build_server_config
from metadata.ingestion.source.pipeline.tableaupipeline.models import (
ExtractTargetType,
TableauFlowLineage,
Expand Down Expand Up @@ -165,7 +164,7 @@ class TableauPipelineClient:

def __init__(
self,
tableau_server_auth: PersonalAccessTokenAuth | TableauAuth,
tableau_server_auth: Credentials,
config: TableauPipelineConnection,
verify_ssl: bool | str | None,
ssl_manager: SSLManager | None = None,
Expand All @@ -190,7 +189,6 @@ def __init__(
config.hostPort,
FALLBACK_API_VERSION,
)
self._auth = tableau_server_auth
self.tableau_server.session.hooks["response"].append(self._sign_in_again)
self.tableau_server.auth.sign_in(tableau_server_auth)
self.config = config
Expand All @@ -215,7 +213,8 @@ def _sign_in_again(self, response: requests.Response, **kwargs: Any) -> requests
"Tableau ended the session: it expired, or the same personal access token signed in elsewhere. "
"Signing in again."
)
self.tableau_server.auth.sign_in(self._auth)
# Fresh credentials: a connected-app JWT expires five minutes after it is signed.
self.tableau_server.auth.sign_in(build_server_config(self.config))
Comment on lines +216 to +217

@gitar-bot gitar-bot Bot Nov 16, 2026 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Quality: Re-sign-in now builds new credentials; the Accepted ADR says the same ones

_sign_in_again no longer reuses the tableau_server_auth passed to the constructor. It now calls build_server_config(self.config) and signs in with what that returns, so a connected-app connection sends a newly signed JWT. The Accepted record ADR:2026-10-30-tableau-pipeline-sign-in-again still says the client signs in "once with the same credentials". Its Guard list doesn't name the new test, and its Consequences still say connected apps would make the rule unnecessary. This PR rewrites only the connected-app ADR's Context so it points at the old record, and leaves the old record contradicting the code.

The change itself is correct, because a JWT expires five minutes after it is signed. The fix is to revise the sign-in-again record to v2 so its Decision says: "A 401 on any call except /auth/ makes the client sign in once with credentials rebuilt from the connection config, so a connected-app sign-in carries a freshly signed JWT, and resend that call once." Also add ::test_a_connected_app_signs_in_again_with_a_fresh_token to its Guard list.

Revise the Decision and Guard lines of docs/decisions/2026-10-30-tableau-pipeline-sign-in-again.md:

- **Revisions:** v1 2026-10-30 (initial); v2 2026-11-04 (sign in again with credentials rebuilt from the config)
...
A 401 on any call except `/auth/` makes the client sign in once with credentials rebuilt from the
connection config (a connected app gets a freshly signed JWT) and send that call once more with the
new token.

Was this helpful? React with 👍 / 👎

resent = request.copy()
# Without this hook, a second 401 reaches the caller instead of another sign-in.
resent.hooks = {"response": []}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,14 @@
from metadata.generated.schema.entity.services.connections.pipeline.tableauPipelineConnection import (
TableauPipelineConnection as TableauPipelineConnectionConfig,
)
from metadata.generated.schema.security.credentials.tableauConnectedAppAuth import (
TableauConnectedAppAuth,
)
from metadata.ingestion.connections.connection import BaseConnection
from metadata.ingestion.connections.test_connections import SourceConnectionException
from metadata.ingestion.source.dashboard.tableau.connection import (
CONNECTED_APP_METADATA_API_FLOOR,
CONNECTED_APP_REJECTED,
METADATA_API_DOC,
TABLEAU_ERRORS,
build_server_config,
Expand All @@ -67,6 +72,12 @@
API_VERSIONS_DOC = "https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_concepts_versions.htm"
JOBS_DOC = "https://help.tableau.com/current/api/rest_api/en-us/REST/rest_api_ref_jobs_tasks_and_schedules.htm"

METADATA_API_REJECTED_FIX = (
"The Tableau Metadata API answered but rejected the flow query, so pipelines and runs will be "
"ingested without lineage. Check the Metadata API is enabled on Tableau Server (it is always on for "
"Tableau Cloud) and that the user can see flows through it."
)

NO_FLOWS_CAVEAT = Diagnosis(
title="No Prep flows visible",
remediation="The site is readable but no published flow is visible to this user. Publish a flow, or grant "
Expand Down Expand Up @@ -115,13 +126,21 @@
),
when(Matchers.exception(GraphQLError)).diagnose(
"Metadata API rejected the query",
fix="The Tableau Metadata API answered but rejected the flow query, so pipelines and runs will be "
"ingested without lineage. Check the Metadata API is enabled on Tableau Server (it is always on for "
"Tableau Cloud) and that the user can see flows through it.",
fix=METADATA_API_REJECTED_FIX,
doc=METADATA_API_DOC,
),
).including(TABLEAU_ERRORS)

# TSC raises FailedSignInError for a 401 with a Tableau error body, including a call outside the token's scopes.
TABLEAU_PIPELINE_CONNECTED_APP_ERRORS = ErrorPack(
when(Matchers.exception(FailedSignInError)).diagnose("Authentication failed", fix=CONNECTED_APP_REJECTED),
when(Matchers.exception(GraphQLError)).diagnose(
"Metadata API rejected the query",
fix=f"{METADATA_API_REJECTED_FIX} {CONNECTED_APP_METADATA_API_FLOOR}",
doc=METADATA_API_DOC,
),
).including(TABLEAU_PIPELINE_ERRORS)


def get_connection(connection: TableauPipelineConnectionConfig) -> TableauPipelineClient:
"""
Expand Down Expand Up @@ -155,10 +174,9 @@ class TableauPipelineChecks:
without them.
"""

errors = TABLEAU_PIPELINE_ERRORS

def __init__(self, server: Borrowed[TableauPipelineClient]) -> None:
def __init__(self, server: Borrowed[TableauPipelineClient], connected_app: bool = False) -> None:
self._server = server
self.errors = TABLEAU_PIPELINE_CONNECTED_APP_ERRORS if connected_app else TABLEAU_PIPELINE_ERRORS

@check(PipelineStep.GetPipelines)
def get_pipelines(self) -> Evidence:
Expand Down Expand Up @@ -215,4 +233,7 @@ def _get_client(self) -> TableauPipelineClient:
return client

def checks(self) -> ChecksProvider:
return TableauPipelineChecks(server=self.borrow())
return TableauPipelineChecks(
server=self.borrow(),
connected_app=isinstance(self.service_connection.authType, TableauConnectedAppAuth),
)
Loading
Loading