Skip to content

feat: configure Kratos for multitenancy from the login UI's relation - #774

Draft
nsklikas wants to merge 1 commit into
multitenancy-specfrom
multitenancy-from-login-ui
Draft

nsklikas wants to merge 1 commit into
multitenancy-specfrom
multitenancy-from-login-ui

Conversation

@nsklikas

@nsklikas nsklikas commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What

When the login UI says it runs Bring Your Own SSO, the charm configures Kratos for it. Stacked on the specification, #773: read that first. This pull request shows only the code. Under the specification is #776, which brings the track up to date with main.

There is no new option: the login UI's charm publishes byosso_enabled over ui-endpoint-info (login_ui_endpoints LIBPATCH 6, canonical/identity-platform-login-ui-operator#543), and while it is "true" the charm sets these together. The code calls the group multitenancy.

in Kratos why
session.whoami.required_aal: aal1, with TOTP and recovery codes enabled as methods whatever enforce_mfa and enable_local_idp say the login UI applies each tenant's MFA policy itself, so a session that has not completed a second factor has to reach /sessions/whoami
selfservice.flows.registration.login_hints: true a first sign-in through a tenant's identity provider onto an existing account goes through Kratos's account linking, which needs the hints
the show_verification_ui hook after a registration through an external provider an address the provider did not mark verified is verified by email before the sign-in completes

Good to know

  • It changes Kratos for every caller. required_aal: aal1 is not per caller: /sessions/whoami, the session list and the check after a login all accept a session with one factor, where an account with a second factor got a 403. Anything that relied on Kratos for the second factor (an Oathkeeper cookie_session authenticator through sessions_endpoint, for instance) no longer gets it.
  • Two options have to fit. Multitenancy needs enable_verification=True and enable_oidc_webauthn_sequencing=False, and enforce_mfa is ignored. With any other configuration the charm blocks, plans nothing and leaves kratos-info as it was, so a running Kratos and what its requirers were told stay as they are. A workload container that is replaced meanwhile gets no layer: Kratos stays down there until the block clears. The login UI's charm refuses the feature on the same two conditions, so the block is reached only by changing these options once the feature is on.
  • Without the flag the rendered configuration is what it is today, but for one line: selfservice.flows.settings.privileged_session_max_age is now set explicitly, to Kratos's own default (1h), and published in kratos-info (LIBPATCH 7). The login UI needs the same age and reads it from there.
  • Turning it off. With the flag off again and enforce_mfa=False, TOTP and recovery codes leave the configuration, while Kratos remembers which accounts enrolled one. Those accounts are asked for a second factor with no method left to give it, until enforce_mfa is set or their second factor is reset (reset-identity-mfa).
  • Open question. With enable_local_idp=False the template renders neither the verification flow nor the code method, so the verification page after an OIDC registration has nothing to show, and a person whose address the provider did not confirm gets an error at every sign-in. The check passes all the same. Either the charm blocks on it too, or the template renders both under multitenancy. Not built.
  • The option descriptions name the login UI's option (byosso_enabled), because the login UI's charm also uses the word multitenancy for the tenants it reads from the Tenant Service.
  • The libraries also go to main, each as a pull request with the library file alone: kratos_info LIBPATCH 7 (feat: add privileged_session_max_age to the kratos_info library #772) and login_ui_endpoints LIBPATCH 6 (feat: add byosso_enabled to the login_ui_endpoints library identity-platform-login-ui-operator#541). They have always changed there first, and main releases them to Charmhub.
  • Order. Besides its base, nothing has to merge before this. The login UI's charm blocks the feature on a Kratos charm without it.

Tests

  • Unit tests for the rendered configuration with and without the flag, the blocked state, and kratos-info.
  • Outside the suite, the template was rendered from this branch and from the track with the flag off, for every combination of the options it reads: nothing differs but the one line.
  • 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. The rename to multitenancy came after it and has unit tests only.
  • Since then the track's base moved to main's code and Kratos 26.2.0 (chore: merge main into track/istio #776). On that base the charm's source for this change is unchanged, 234 unit tests pass, and the keys the change sets were checked against the configuration schema of Kratos 26.2.0. It was not deployed on that base.

@nsklikas
nsklikas force-pushed the multitenancy-from-login-ui branch from f663c30 to c814ed9 Compare October 13, 2026 16:05
@nsklikas
nsklikas force-pushed the multitenancy-from-login-ui branch from c814ed9 to 8786a90 Compare October 13, 2026 17:05
@nsklikas
nsklikas force-pushed the multitenancy-from-login-ui branch from 8786a90 to d283902 Compare October 13, 2026 18:26
nsklikas added a commit that referenced this pull request Oct 23, 2026
## What

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

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

- **The Kratos image 26.2.0** (the track pinned 25.4.0).
- **Bases**: `ubuntu@22.04:arm64`, `ubuntu@26.04:amd64` and
`ubuntu@26.04:arm64`, next to `ubuntu@22.04:amd64`.
- **`ui-endpoint-info`** is limited to one integration, and the charm
reconfigures when it is removed.
- **The `uv` build**, and the dependency updates since June (`ops` 3.9,
`lightkube` 0.22, `pydantic` 2.14).
- **CI**: the shared workflows at v1.17.0, `use-charmcraftcache: false`
and the workflow permissions. Without them a pull request against the
track cannot build today (charmcraftcache finds no cache for it), and a
manual run of `publish.yaml` fails to start.

## Good to know

- **How to read it.** Compare the branch with `main`: the difference is
the Istio change alone, 28 files. For five of the six files that both
sides had changed, that difference is exactly the track's own patch.
Only `tests/unit/test_charm.py` needed work: `main`'s two new tests for
`ui-endpoint-info` used the Traefik template mock that the track
removed.
- **`ci.yaml` keeps the track's `"**"`** for the base branches of pull
requests. `main`'s `"*"` does not match `track/istio`.
- **The release files are `main`'s.** The manifest says 2.4.2, where the
track had 2.2.1, so a release from the track would continue `main`'s
numbers. 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**: `README.md` still documents the Traefik integrations
(the track never updated it), and `openspec validate --all --strict`
fails for the track's two specifications as it did before (they are in
delta format).
- The Bring Your Own SSO pull requests are stacked on this one: #773,
then #774.

## Tests

- Lint passes. 220 unit tests pass under `main`'s `-Werror`: the track's
218 and `main`'s 2 new ones.
- In CI the charm builds. The integration tests were not run locally
(`main` did not change them). Not deployed.
When the login UI publishes `byosso_enabled: "true"` over
ui-endpoint-info (login_ui_endpoints LIBPATCH 6), the charm configures
Kratos for it, with no new option:

- session.whoami.required_aal is aal1, with TOTP and recovery codes
  enabled whatever enforce_mfa and enable_local_idp say, because the
  login UI then applies each tenant's MFA policy itself;
- registration login hints are on;
- the verification page is shown after a registration through an
  external provider.

Multitenancy needs enable_verification and no OIDC-WebAuthn sequencing.
With any other configuration the charm blocks, plans nothing and leaves
kratos-info as it was.

Without the flag the rendered configuration is what it was, but for one
line: the age of a privileged session is set explicitly (1h, Kratos's
default) and published in kratos-info (LIBPATCH 7), where the login UI
reads it.
@nsklikas
nsklikas force-pushed the multitenancy-from-login-ui branch from d283902 to 8d4dd8d Compare October 23, 2026 11:57
nsklikas added a commit 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 to canonical/identity-platform-login-ui-operator 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