Skip to content

Add TLS configuration options for auth#536

Merged
DaleSeo merged 9 commits intomainfrom
AMS-340
Jan 7, 2026
Merged

Add TLS configuration options for auth#536
DaleSeo merged 9 commits intomainfrom
AMS-340

Conversation

@DaleSeo
Copy link
Copy Markdown
Member

@DaleSeo DaleSeo commented Jan 5, 2026

Fixes #534

This PR adds TLS configuration options for connecting to OAuth servers during token validation.

When the MCP server validates OAuth tokens, it connects to upstream OAuth servers to fetch JWKS keys. Previously, this required those servers to have certificates trusted by the system's default CA bundle. This change allows users to trust custom CA certificates or disable validation for development environments.

transport:
  streamable_http:
    auth:
      servers:
        - https://auth.example.com
      audiences:
        - my-audience
      resource: https://mcp.example.com/mcp
      tls:
        ca_cert: /path/to/ca-certificate.pem
        danger_accept_invalid_certs: false  # dev/testing only

@apollo-librarian
Copy link
Copy Markdown
Contributor

apollo-librarian Bot commented Jan 5, 2026

✅ Docs preview ready

The preview is ready to be viewed. View the preview

File Changes

0 new, 1 changed, 0 removed
* (developer-tools)/apollo-mcp-server/(latest)/config-file.mdx

Build ID: 832c47fee3ca8afb12add2fc
Build Logs: View logs

URL: https://www.apollographql.com/docs/deploy-preview/832c47fee3ca8afb12add2fc

@DaleSeo DaleSeo changed the title Add TLS configuration Add TLS configuration options for auth Jan 5, 2026
jsonschema = "0.33.0"
jsonwebtoken = "9"
jwks = "0.4.0"
jwks = { git = "https://github.com/chenhunghan/jwks", tag = "v0.5.1" }
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

We pinned the jwks crate to v0.5.1 directly from Git because this version includes chenhunghan/jwks#19, which adds support for using a custom reqwest::Client. This is necessary for our TLS configuration feature. Without it, we wouldn't be able to use a client set up with custom CA certificates. This version hasn't been published to crates.io yet.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for the clarification @DaleSeo ! Is there an existing issue upstream asking for a crates.io publish, or should we open one?

Copy link
Copy Markdown
Member Author

@DaleSeo DaleSeo Jan 6, 2026

Choose a reason for hiding this comment

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

There's an existing issue: chenhunghan/jwks#27. Looks like the publish to crates.io failed in https://github.com/chenhunghan/jwks/actions/runs/17892875856/job/50875615384. Once that's resolved, we can switch back from the Git dependency.

@DaleSeo DaleSeo marked this pull request as ready for review January 5, 2026 18:58
@DaleSeo DaleSeo requested a review from a team as a code owner January 5, 2026 18:58
@DaleSeo DaleSeo self-assigned this Jan 5, 2026
Comment thread crates/apollo-mcp-server/src/auth.rs Outdated
Comment thread crates/apollo-mcp-server/src/auth.rs
Copy link
Copy Markdown
Member Author

@DaleSeo DaleSeo left a comment

Choose a reason for hiding this comment

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

Really appreciate your thorough review, @gocamille! You caught some great issues. I've refactored the code to build the HTTP client once at startup instead of on every request. This way, any invalid TLS configuration will fail immediately when the server starts, and we won't have to read the certificate file for every authenticated request.

The tradeoff is that we lose hot certificate rotation. If you update the CA cert file, you'll need to restart the server to pick up the change. I think this is the right default since cert rotation is rare and the performance and fail-fast benefits outweigh it. If hot rotation becomes a requirement down the road, we can add it later with a file watcher or periodic reload.

jsonschema = "0.33.0"
jsonwebtoken = "9"
jwks = "0.4.0"
jwks = { git = "https://github.com/chenhunghan/jwks", tag = "v0.5.1" }
Copy link
Copy Markdown
Member Author

@DaleSeo DaleSeo Jan 6, 2026

Choose a reason for hiding this comment

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

There's an existing issue: chenhunghan/jwks#27. Looks like the publish to crates.io failed in https://github.com/chenhunghan/jwks/actions/runs/17892875856/job/50875615384. Once that's resolved, we can switch back from the Git dependency.

@DaleSeo DaleSeo requested a review from gocamille January 6, 2026 15:51
Copy link
Copy Markdown
Contributor

@gocamille gocamille left a comment

Choose a reason for hiding this comment

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

Thank you for this PR @DaleSeo !

Copy link
Copy Markdown
Contributor

@mabuyo mabuyo left a comment

Choose a reason for hiding this comment

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

Minor language consistency edits!

Comment thread .changesets/feat_tls_config.md Outdated
Comment thread docs/source/config-file.mdx Outdated
Comment thread docs/source/config-file.mdx Outdated
| `scopes` | `List<string>` | | List of queryable OAuth scopes from the upstream OAuth servers |
| `disable_auth_token_passthrough` | `bool` | `false` | Optional flag to disable passing validated Authorization header to downstream API |
| `tls.ca_cert` | `string` | | Path to a CA certificate to trust (PEM format). |
| `tls.danger_accept_invalid_certs`| `bool` | `false` | Accept invalid TLS certificates. Warning: Insecure. Use only for development or testing. |
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
| `tls.danger_accept_invalid_certs`| `bool` | `false` | Accept invalid TLS certificates. Warning: Insecure. Use only for development or testing. |
| `tls.danger_accept_invalid_certs`| `bool` | `false` | Accepts invalid TLS certificates. Set this to `true for development or testing purposes only. |

(This might need spacing fixes)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thanks @mabuyo for reviewing the doc updates! I applied your suggestions and had the file reformatted.

@DaleSeo DaleSeo enabled auto-merge January 7, 2026 14:17
@DaleSeo DaleSeo merged commit 133d724 into main Jan 7, 2026
11 checks passed
@DaleSeo DaleSeo deleted the AMS-340 branch January 7, 2026 14:20
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.

OAuth validation fails when Keycloak uses self-signed HTTPS certificate

3 participants