Skip to content

[Cherry-pick to branch-1.3] [#12447] fix(mcp-server): Preserve the authorization scheme for static credentials (#12439) - #12462

Merged
yuqi1129 merged 1 commit into
branch-1.3from
cherry-pick-5871b08b-to-branch-1.3
Aug 14, 2026
Merged

[Cherry-pick to branch-1.3] [#12447] fix(mcp-server): Preserve the authorization scheme for static credentials (#12439)#12462
yuqi1129 merged 1 commit into
branch-1.3from
cherry-pick-5871b08b-to-branch-1.3

Conversation

@github-actions

Copy link
Copy Markdown

Cherry-pick Information:

  • Original commit: 5871b08
  • Target branch: branch-1.3
  • Status: ✅ Clean cherry-pick (no conflicts)

…c credentials (#12439)

### What changes were proposed in this pull request?

The MCP server now accepts a complete static authorization credential
through `--token` or `GRAVITINO_TOKEN`.

A bare value remains an OAuth2 Bearer token for backward compatibility.
A value containing a syntactically valid HTTP authentication scheme and
credentials is forwarded as an Authorization credential.

```
--token "abc"                    sends   Authorization: Bearer abc
--token "Bearer abc"             sends   Authorization: Bearer abc
--token "Basic dXNlcjpwYXNz"     sends   Authorization: Basic dXNlcjpwYXNz
--token "Custom credentials"     sends   Authorization: Custom credentials
--token ""                       sends   no header
```

The patch:

- Detects authorization credentials using the RFC 9110 scheme syntax
instead of a fixed scheme allowlist.
- Canonicalizes the built-in `Basic`, `Bearer`, and `Negotiate` scheme
names because the corresponding Gravitino authenticators currently match
them case-sensitively.
- Preserves valid custom scheme names for custom Gravitino
authenticators.
- Treats empty and whitespace-only static tokens as anonymous.
- Updates the `Setting.token` documentation and `--token` help text.
- Adds unit coverage for built-in, custom, malformed, empty, whitespace,
and compatibility cases.

### Why are the changes needed?

The MCP server forwards credentials to Gravitino but does not
authenticate them itself. An incoming `Authorization` header is already
forwarded unchanged, while the static `--token` fallback was always
prefixed with `Bearer`.

Consequently, an MCP client that cannot attach its own header could not
connect to a Gravitino server configured with `gravitino.authenticators
= basic`. Supplying a Basic credential through `--token` produced
`Authorization: Bearer Basic <credentials>` and failed with:

```
Error code: 1011, Error type: UnauthorizedException,
Error message: The provided credentials did not support
```

This change lets the static fallback express the authentication scheme
required by Gravitino while preserving the existing behavior for bare
OAuth2 tokens.

Fix: #12447

### Does this PR introduce _any_ user-facing change?

Yes. `--token` and `GRAVITINO_TOKEN` now accept complete credentials
using any syntactically valid HTTP authentication scheme. Bare values
continue to be sent as Bearer tokens, and whitespace-only values now
send no Authorization header.

Built-in scheme names are canonicalized case-insensitively, and a value
already beginning with `Bearer ` is no longer double-prefixed. No CLI
arguments or environment variables are added or removed.

### How was this patch tested?

```shell
cd mcp-server
python -m pytest tests/unit/test_auth_flow.py -v
python -m pytest tests/unit -q
```

The targeted file has 24 passing tests, and all 184 MCP unit tests pass.
`./gradlew spotlessApply` succeeds, and `pylint` reports 10.00 for the
changed files.

The Basic credential path was also verified on Kubernetes against
Gravitino 1.3 configured with `authenticators: basic`. The same MCP
`tools/call` that failed before the change succeeds after it.

---------

Co-authored-by: Mark Hoerth <mark@datastrato.com>
Co-authored-by: yuqi <yuqi@datastrato.com>
@github-actions github-actions Bot added the cherry-pick Automatically opened cherry-pick PR label Aug 14, 2026
@github-actions
github-actions Bot requested a review from jerryshao August 14, 2026 01:48
@yuqi1129
yuqi1129 merged commit 03141b0 into branch-1.3 Aug 14, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick Automatically opened cherry-pick PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants