Skip to content

feat: add Bring Your Own SSO behind byosso_enabled - #543

Draft
nsklikas wants to merge 1 commit into
bring-your-own-sso-specfrom
bring-your-own-sso
Draft

nsklikas wants to merge 1 commit into
bring-your-own-sso-specfrom
bring-your-own-sso

Conversation

@nsklikas

@nsklikas nsklikas commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What

Lets an operator turn on the login UI's Bring Your Own SSO (canonical/identity-platform-login-ui#993): tenants sign their members in with their own OIDC identity provider, and each tenant's MFA policy replaces the platform-wide rule. Off by default. Stacked on the specification, #542: read that first. This pull request shows only the code. Under the specification is #545, which brings the track up to date with main.

  • byosso_enabled. It needs the tenant-service-info, sso-service-info and kratos-info integrations, a Kratos charm that publishes its privileged session age, and Kratos with enable_verification and without OIDC/WebAuthn sequencing: the two conditions Kratos's charm refuses the feature on.
  • sso-service-info (requirer): the SSO Service's gRPC address.
  • ui-endpoint-info gains byosso_enabled (login_ui_endpoints LIBPATCH 6): "true" or "false" as the option says. kratos-operator configures Kratos from it (feat: configure Kratos for multitenancy from the login UI's relation kratos-operator#774).
  • KRATOS_PRIVILEGED_SESSION_MAX_AGE comes from kratos-info (privileged_session_max_age, LIBPATCH 7). For a Kratos charm that does not publish it the charm blocks and says to refresh Kratos.
  • The route /api/v0/sso/complete, where a sign-in through a tenant's identity provider that started outside an app's login ends.
  • No client of its own. The login UI's calls to the Tenant Service and the SSO Service carry no token, as its tenant lookup does today, so the charm has no oauth relation.

With the option off

The charm plans the layer it plans today. Four things change all the same: the route /api/v0/sso/complete is on the gateway, ui-endpoint-info carries byosso_enabled: "false", the charm has the sso-service-info endpoint (in the Terraform module's outputs too) and does not use it, and the charm cannot be built without the git dependency below.

Good to know

  • While something is missing the charm plans nothing. The login UI refuses to start when the feature is on and something is missing, so the charm keeps the running layer and says in its status what is missing. A container that is replaced meanwhile has no layer to keep: the login UI stays down until the requirement is met.
  • While the charm is blocked it writes nothing to ui-endpoint-info: what Kratos was told stays, and a Kratos that relates meanwhile is told nothing until the block clears. Otherwise the field is written after each plan, and with the endpoints when a requirer relates or the public route changes, so it can come before the workload runs the feature.
  • Kratos changes for every caller. With the feature applied Kratos runs with session.whoami.required_aal: aal1: its /sessions/whoami and its session list accept a session that has one factor, where they answered 403 for an account with a second factor. The login UI asks for the second factor itself before it accepts a sign-in; anything else that relied on Kratos for it (an Oathkeeper cookie_session authenticator, for instance) no longer gets it.
  • The library comes from git. Charmhub takes no new libraries, so sso_service_info is not fetched with charmcraft fetch-lib: the charm depends on the package sso-service-info, pinned in pyproject.toml and uv.lock at canonical/sso-service-operator@02c6895, the tip of feat: add the sso-service charm sso-service-operator#4, and git is added to the build packages. The pin has to be redone once that pull request merges.
  • Before this merges: the image. The charm pins identity-platform-login-ui:v0.28.0, which does not have the feature and ignores BYOSSO_ENABLED. On that image the option would report Active and tell Kratos "true" while the login UI applies the platform's MFA rule; with Kratos at aal1 a password sign-in of a user with a second factor then ends in a 403 at consent. The pin has to move, in this pull request, to the login UI release that contains feat: add Bring Your Own SSO behind BYOSSO_ENABLED identity-platform-login-ui#993.
  • Before the feature can be turned on anywhere: the Tenant Service. Its charm pins tenant-service:v0.2.0, and no release has the two services the login UI calls with the feature on (feat: add tenant SSO policy, sign-in context and pending invitations tenant-service#140). On such an image this charm reports Active, Kratos is switched to aal1, and every tenant lookup answers Unimplemented: nobody signs in to an app. Nothing here can detect it; the pin in the Tenant Service's charm has to move first.
  • Turning it off, rolling back. Turn the option off before refreshing the charm back to a revision without it: an older revision never clears byosso_enabled from the relation data, so Kratos would stay at aal1 under a login UI that expects Kratos to ask for the second factor. For the moment between this charm's hook and Kratos's the same holds when the option is turned off.
  • What the charm cannot check. The SSO Service's pages have to be served on the same host as the login UI.
  • It needs feat: configure Kratos for multitenancy from the login UI's relation kratos-operator#774 deployed first: this charm blocks the feature on a Kratos charm without it.
  • The library also goes to main, as a pull request with the library file alone: login_ui_endpoints LIBPATCH 6 (feat: add byosso_enabled to the login_ui_endpoints library #541), as kratos_info LIBPATCH 7 does (feat: add privileged_session_max_age to the kratos_info library kratos-operator#772). The libraries have always changed there first, and main releases them to Charmhub.

Tests

  • Unit tests for each blocked and waiting state, the planned environment with the option on and off, what is published to Kratos in each, and the route.
  • An earlier version of this change was deployed with the rest of the platform on MicroK8s (Juju 3.6, Istio, Hydra and Kratos 25.4.0): a browser suite of 84 sign-in cases passed twice in a row. That charm decided what to tell Kratos from the workload's Pebble plan and vendored the sso_service_info library. As proposed, the charm decides from its configuration and relations and installs the library from git: that has unit tests only.
  • Since then the track's base moved to main's code and its uv build (chore: merge main into track/istio #545). On that base the charm's source for this change is unchanged, 50 unit tests pass, and the build's uv sync was run with the pinned package: it needs git, which is why git is in the build packages. The charm was not deployed on that base.

@github-actions

Copy link
Copy Markdown
Contributor

Terraform Format and Style 🖌success

Terraform Initialization ⚙️success

Terraform Validation 🤖success

Validation Output

Success! The configuration is valid.


Pusher: @nsklikas, Action: pull_request, Workflow: Pull Request on Terraform Module

@nsklikas
nsklikas force-pushed the bring-your-own-sso-spec branch from 6977cc9 to 12de7c0 Compare October 13, 2026 16:05
@nsklikas
nsklikas force-pushed the bring-your-own-sso-spec branch from 12de7c0 to 601c473 Compare October 13, 2026 17:08
@nsklikas
nsklikas force-pushed the bring-your-own-sso-spec branch from 601c473 to f6f2205 Compare October 13, 2026 18:26
nsklikas added a commit that referenced this pull request Nov 17, 2026
## What

Brings the Istio track up to date with `main`. The track left `main` in
June and lacked its 139 commits since. The tree of this branch is `main`
as it is today with the track's one change kept: the public route over
`istio-ingress-route` (#465), with its tests, its migration document and
its OpenSpec files. One merge commit; its message lists the eight files
that both sides had changed.

What the track's charm gets from `main`:

- **The image `identity-platform-login-ui:v0.28.0`** (the track pinned
v0.27.0), and with `tenant-service-info` the workload gets
`TENANT_SERVICE_GRPC_ADDRESS` instead of `TENANTS_SERVICE_URL`, which
v0.28.0 does not read.
- **Bases**: `ubuntu@22.04:arm64`, `ubuntu@26.04:amd64` and
`ubuntu@26.04:arm64`, next to `ubuntu@22.04:amd64`.
- **The `uv` build**, and the dependency updates since June (`lightkube`
1.0, `pydantic` 2.14, `tenacity` 9.2).
- **CI**: the shared workflows at v1.17.0, `use-charmcraftcache: false`,
the OpenSpec check and the drift job. Without the charmcraftcache
setting a pull request against the track cannot build today
(charmcraftcache finds no cache for it).

## Good to know

- **How to read it.** Compare the branch with `main`: the difference is
the Istio change and the track's own OpenSpec prompts and skills, 32
files. For the source files, the fixtures and the tests, that difference
is exactly the track's own patch.
- **Two things a plain merge would have got wrong:**
- `charmcraft.yaml`: `main` has a `templates` part that primes
`templates/`. The track deleted the only template with the Traefik
route, so the directory does not exist and the part is dropped. This is
from reading how charmcraft primes a missing path: the build job of this
pull request is its proof.
- `pyproject.toml`: `charmlibs-interfaces-istio-ingress-route==1.0.2`
replaces `jinja2`, as the track's `requirements.txt` had it. Nothing in
`src/` imports `jinja2`.
- **`ci.yaml` keeps the track's `"**"`** for the base branches of pull
requests. `main`'s `"*"` does not match `track/istio`.
- **The integration tests are the track's.** `main`'s revision pin is
for the Traefik charm, which they do not deploy. `main`'s test helpers
constrain the model to the host's architecture, and the Istio charms
have only amd64 revisions on `2/stable`: on an arm64 runner the track's
tests cannot deploy them.
- **The release files are `main`'s.** The manifest says 2.4.0, where the
track had 2.2.1 and never cut a release. To decide: whether the track
keeps a version line of its own.
- **One more commit, in the integration tests**: they deployed the Istio
control plane and its gateways at the same time. The gateway charm lists
Istio's AuthorizationPolicy resources in its first hooks, and when those
ran before `istio-k8s` had installed the CRDs the hook failed and the
tests had no gateway address. The tests now wait for the control plane
first.
- **Merge it with a merge commit, not a squash**, so that `main`'s
history is in the track and the next merge of `main` is small.
- **Not changed**: `openspec validate --all --strict` fails for the
track's specification `istio-public-route` as it did before (it has no
Purpose section); `main`'s OpenSpec check validates active changes only
and passes. #542 gives that file its header.
- **It replaces #539**: the image pin and the Tenant Service address
that pull request picked from `main` come with this merge. The Bring
Your Own SSO pull requests are stacked on this one: #542, then #543.

## Tests

- Lint passes. 27 unit tests pass (the track has 27, `main` 21).
- In CI the charm builds and the integration tests pass (MicroK8s, with
`istio-k8s` and `istio-ingress-k8s`). Not deployed with the rest of the
platform.
The option `byosso_enabled` turns on the login UI's "Bring Your Own
SSO": tenants sign their members in with their own OIDC identity
provider, and each tenant's MFA policy replaces the platform-wide rule.
It is off by default, and with it off the charm plans the layer it
planned before.

The feature needs the tenant-service-info, sso-service-info and
kratos-info integrations, a Kratos charm that publishes the age of a
privileged session, and Kratos with verification and without
OIDC-WebAuthn sequencing. While one of them is missing the charm reports
it and plans nothing, so the running workload stays as it is.

The charm tells Kratos over ui-endpoint-info whether the feature is on
(login_ui_endpoints LIBPATCH 6), and writes nothing while it is blocked
on the feature. It passes the age of a privileged session on from
kratos-info, and it adds the route /api/v0/sso/complete.

The sso_service_info library is a Python package of
canonical/sso-service-operator, installed from git at a pinned commit,
because Charmhub takes no new libraries.
@nsklikas
nsklikas force-pushed the bring-your-own-sso-spec branch from f6f2205 to 66ed413 Compare November 17, 2026 13:39
nsklikas added a commit to canonical/kratos-operator that referenced this pull request Nov 23, 2026
## What

`kratos_info` LIBPATCH 7, the library file alone.

The provider can publish the age of a privileged session
(`privileged_session_max_age`), and the requirer reads it with the rest
of the data. The charm on the Istio track publishes the field (#774),
and the login UI's charm reads it
(canonical/identity-platform-login-ui-operator#543).

## Why

With Bring Your Own SSO, the login UI lets a user remove an SSO sign-in
from their account (Connected accounts). Kratos does not do this
removal: the login UI asks the SSO service, which removes the link
through Kratos's admin API. So Kratos does not check the age of the
session, and the login UI must do it as Kratos does for its own unlink:
a session older than `privileged_session_max_age` must sign in again
first.

The login UI must use the same value as Kratos. With a different value,
it asks for a new sign-in where Kratos does not, or it lets an older
session remove a sign-in when Kratos refuses the same session for its
own unlink. The login UI's charm reads the value from this relation, and
it does not enable Bring Your Own SSO without it.

## Good to know

- **Nothing changes for this charm on `main`.** The argument is
optional: a provider that does not pass it publishes exactly what it
published before, and `main` does not pass it.
- **Why on `main`.** This library has always changed on `main` first,
and `main` releases it to Charmhub. With the patch on the track only,
the next change of the library on `main` would take the same patch
number for other content.
- Nothing has to merge before this, and it can merge at any time.

## Tests

The repository's unit tests and lint pass with the new library file. The
field has no test here, because nothing on `main` uses it; #774 tests
it.
nsklikas added a commit that referenced this pull request Nov 23, 2026
## What

`login_ui_endpoints` LIBPATCH 6, the library file alone.

The provider can say whether the login UI runs Bring Your Own SSO
(`byosso_enabled`, `"true"` or `"false"`). The charm on the Istio track
publishes the field (#543), and kratos-operator's reads it
(canonical/kratos-operator#774).

## Good to know

- **Nothing changes for this charm on `main`.** The field is optional: a
provider that does not set it publishes exactly what it published
before, and a requirer reads a missing value as off. `main` does not set
it.
- **Why on `main`.** This library has always changed on `main` first,
and `main` releases it to Charmhub. With the patch on the track only,
the next change of the library on `main` would take the same patch
number for other content.
- Nothing has to merge before this, and it can merge at any time.

## Tests

The repository's unit tests and lint pass with the new library file. The
field has no test here, because nothing on `main` uses it; #543 tests
it.
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