Skip to content

patch: receive the OAuth identity provider CA bundle - #513

Open
delgod wants to merge 3 commits into
8/edgefrom
oidc-ca-certificates
Open

delgod wants to merge 3 commits into
8/edgefrom
oidc-ca-certificates

Conversation

@delgod

@delgod delgod commented Oct 13, 2026

Copy link
Copy Markdown
Member

🏷️ Type of changes

  • New feature (non-breaking change which adds functionality)
  • Dependencies upgrade or change

📝 Description

First half of the OAuth integration (DA287): receive the identity provider's CA certificates. The integration itself (oauth, serverCAFile, restarts, validation) is out of scope.

  • New optional endpoint oauth-certificate-transfer (certificate_transfer v1) on mongodb, and a new peer relation oauth-peers on all charms.
  • Each unit stores the certificates and writes {ETC}/oauth/certs/oauth-ca.crt plus a charm copy in /usr/local/share/ca-certificates/oauth.crt.
    A charm copy in /usr/local/share/ca-certificates/oauth.crt is needed later to validate that curl <issuer_url>/.well-known/openid-configuration works.
  • The config-server shares the bundle with routers (oauth-ca-secret on cluster); routers write the same bundle file.
  • Blocked statuses:
    • certificates that are not valid PEM: the unit keeps its last valid set;
    • the relation on a shard.

Nothing reads the bundle yet, and nothing restarts.

⚠️ Charms bumping to this version must declare oauth-peers (all four charms) and oauth-certificate-transfer (mongodb, mongodb-k8s).

🧪 Manual testing steps

juju integrate mongodb:oauth-certificate-transfer self-signed-certificates:send-ca-cert
juju ssh mongodb/0 sudo cat /var/snap/charmed-mongodb/current/etc/oauth/certs/oauth-ca.crt

🔬 Automated testing steps

Unit tests: test_oauth_manager.py, test_oauth_router.py, test_oauth_state.py, test_cluster_manager.py. No integration tests yet; the follow-up oauth PR covers the CA relation end-to-end.

delgod and others added 3 commits October 13, 2026 13:56
Adds the oauth-certificate-transfer endpoint (certificate_transfer v1 through
PyPI charmlibs-interfaces-certificate-transfer) on the mongodb charms, the
oauth-peers peer relation on all four charms, the workload bundle path
{ETC}/oauth/certs/oauth-ca.crt and the charm copy oauth.crt in the trust-anchor
directory. OAuthState keeps each unit's CA chain in a unit secret, shaped
like LdapState. The cluster relation gains oauth-ca-secret, which routers
request as a secret field next to int-ca-secret and ext-ca-secret.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every mongodb unit stores the certificate set it receives over
oauth-certificate-transfer, writes the bundle for the workload and a copy for
the charm, and removes both with the relation or an empty set; shards ignore
the relation (logged). A config-server leader publishes the bundle to every
router as oauth-ca-secret and removes it with the relation. Routers copy it
into their own chain and bundle file on every start and restart, without a
charm copy. The bundle is re-written on start and refresh like the LDAP
certificates.

Nothing reads the bundle yet and nothing restarts: the OAuth integration
renders it as serverCAFile and validates the identity provider through the
charm copy.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each certificate set from oauth-certificate-transfer is parsed as PEM X.509
before it is stored (an entry may hold several certificates). A set that does
not parse is not stored: the unit keeps its last valid chain and files and
reports Blocked "identity provider CA certificates are not valid PEM" until
the provider sends a valid set or the relation goes away. A certificate
without the CA basic constraint is only logged: a pinned server certificate
is a valid trust anchor for libcurl, which accepts partial chains.

A shard with the CA relation now reports Blocked "OAuth is not supported on
shards" instead of only logging it. The OAuth manager joins the mongodb
components (unit scope, component `oauth`); its statuses come from the
relation data, so the status handler's recompute keeps them current.
Routers report no status.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant