Skip to content

Commit f6f2205

Browse files
committed
docs(spec): add and archive the bring-your-own-sso specification
The specification covers the option byosso_enabled: the checks that the charm makes before it plans the workload with the feature, the status for each check that fails, the environment of the workload, and the field byosso_enabled that the leader writes in ui-endpoint-info. It adds the route /api/v0/sso/complete to the istio-public-route specification. That file also gets its title, a Purpose section and the Requirements heading, because the openspec archive command needs them to update the file.
1 parent a1e57e1 commit f6f2205

6 files changed

Lines changed: 416 additions & 1 deletion

File tree

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
schema: spec-driven
2+
created: 2026-10-13
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
## Context
2+
3+
The login UI runs "Bring Your Own SSO" when its setting `BYOSSO_ENABLED` is on. With the feature, the login UI calls the Tenant Service and the SSO Service over gRPC. It also decides itself when a sign-in needs MFA. The login UI refuses to start when the feature is on and something that the feature needs is absent.
4+
5+
The charm already has 2 of the relations that the feature needs. The `tenant-service-info` relation gives the address of the Tenant Service, and the `kratos-info` relation gives the settings of Kratos. The charm also gives its endpoint URLs to other charms in `ui-endpoint-info`. The Kratos charm is one of the charms that read that relation.
6+
7+
In this document, to plan the workload is to give Pebble the layer of the service and to start or replan the service.
8+
9+
## Goals / Non-Goals
10+
11+
**Goals:**
12+
13+
- One option turns the feature on. The charm gets all other values from its relations.
14+
- The unit status tells the operator what the feature needs.
15+
- The charm leaves a workload that runs the feature as it is when a relation goes away.
16+
17+
**Non-Goals:**
18+
19+
- The configuration of Kratos for the feature. The Kratos charm does that work.
20+
- Credentials for the calls to the Tenant Service and the SSO Service. The login UI makes these calls with no token.
21+
- A check that the workload image has the feature.
22+
23+
## Decisions
24+
25+
### 1. The charm plans nothing while a check fails
26+
27+
**Decision:** While the option is on and a check of the feature fails, the charm sets its status and stops before the plan. It does not plan the workload with the feature, and it does not plan the workload without the feature.
28+
29+
**Reason:** The login UI refuses to start when `BYOSSO_ENABLED` is on and something that it needs is absent. A login UI with the feature off does not enforce the sign-in policies of the tenants. Thus the 2 possible plans are both wrong, and the charm leaves the workload as it is.
30+
31+
**Alternatives that we turned down:**
32+
33+
- A plan without the feature until all the checks pass. With such a plan, a relation that goes away stops the enforcement of the sign-in policies of the tenants.
34+
- A plan with the feature. The service does not start with such a plan.
35+
36+
### 2. The checks include 2 settings of Kratos
37+
38+
**Decision:** The charm blocks the feature when Kratos runs with OIDC-WebAuthn sequencing, and when Kratos runs without verification. The charm reads both settings from `kratos-info`.
39+
40+
**Reason:** The charm relies on the Kratos charm to block on the same 2 settings. Without these checks, the login UI runs the feature while Kratos is not configured for the feature.
41+
42+
### 3. The charm tells Kratos in ui-endpoint-info, and takes the value from its option
43+
44+
**Decision:** The leader writes `byosso_enabled` in `ui-endpoint-info`. The value is the text `true` or the text `false`, as the option says. The leader writes the field after each plan that succeeds, and together with the endpoint URLs. It does not write the field while a check of the feature fails.
45+
46+
**Reason:** There are 2 reasons:
47+
48+
- Kratos must change its configuration only for a login UI that the charm plans with the feature.
49+
- While a check fails, the workload stays as it is. Thus the value that Kratos has must also stay as it is. If the charm writes `false` at that time, Kratos and a workload that runs the feature disagree.
50+
51+
**Alternative that we turned down:** A value that the charm reads from the Pebble plan and from the state of the service. That value needs calls to Pebble in each hook. The option and the checks give the charm its answer without those calls.
52+
53+
### 4. The age of a privileged session comes from kratos-info
54+
55+
**Decision:** The charm passes the `privileged_session_max_age` of `kratos-info` to the workload as `KRATOS_PRIVILEGED_SESSION_MAX_AGE`. The charm has no option for this value. When `kratos-info` does not have the field, the charm blocks the feature and tells the operator to refresh the Kratos charm.
56+
57+
**Reason:** The login UI must apply the same age as Kratos. Kratos knows the age that it runs with, so the charm takes the value from there.
58+
59+
**Alternative that we turned down:** An option of this charm. Such an option is a second copy of the value, and the operator must keep the 2 copies equal.
60+
61+
The status for an absent field is blocked and not waiting. The field does not arrive until the operator refreshes the Kratos charm, and the message says so.
62+
63+
### 5. The sso_service_info library is a Python package from git
64+
65+
**Decision:** The charm installs the library as the Python package `sso-service-info`. The package comes from a commit of the repository of the SSO Service charm, from its directory `interfaces/sso_service_info`. The pin is in `pyproject.toml` and in `uv.lock`, and `git` is in the build packages of the charm.
66+
67+
**Reason:** Charmhub takes no new libraries. Thus `charmcraft fetch-lib` cannot get this library.
68+
69+
## Risks / Trade-offs
70+
71+
- **A new container while a check fails.** The charm adds no layer to a workload container that starts while a check fails. The charm does not start the service there until all the checks pass. The unit status shows the check that fails.
72+
- **The value in ui-endpoint-info can be ahead of the workload.** The leader writes the field with the endpoint URLs when a `ui-endpoint-info` relation is created. That write can come before the first plan, and after a plan that failed. The charm does not read the workload, so the text `true` does not prove that the service runs.
73+
- **The 2 charms act in different hooks.** After the operator changes the option, this charm plans the workload first. The Kratos charm changes Kratos later, in a hook of its own. Between the 2 hooks, Kratos and the login UI can disagree about the feature.
74+
- **An older revision of the charm.** A revision from before this change does not write `byosso_enabled`. After a refresh to such a revision, the last value stays in the relation data. Turn the option off before such a refresh.
75+
- **The build needs the repository of the SSO Service charm.** The build of the charm gets the library with `git`. The commit in `pyproject.toml` and in `uv.lock` must exist in that repository.
76+
- **The charm checks relation data only.** The charm does not check that the Tenant Service and the SSO Service answer at their addresses.
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
## Why
2+
3+
The login UI has a feature, "Bring Your Own SSO". With this feature, a tenant registers its own OIDC identity provider, and the members of the tenant sign in with that provider. The login UI then also decides when a sign-in needs MFA.
4+
5+
The charm has no way to turn the feature on. The workload needs 3 values from other charms to run the feature:
6+
7+
- The address of the Tenant Service.
8+
- The address of the SSO Service.
9+
- The age of a privileged session of Kratos.
10+
11+
Kratos must also know that the login UI runs the feature.
12+
13+
## What Changes
14+
15+
- A new boolean option, `byosso_enabled`, turns the feature on. The default is `false`.
16+
- A new relation endpoint, `sso-service-info`, gives the charm the gRPC address of the SSO Service. Its interface is `sso_service_info`.
17+
- While the option is on, the charm makes these checks before each plan of the workload:
18+
- The `tenant-service-info`, `sso-service-info` and `kratos-info` relations exist, and each has its data.
19+
- `kratos-info` has a `privileged_session_max_age`.
20+
- Kratos runs with verification and without OIDC-WebAuthn sequencing.
21+
- While a check fails, the unit status shows that check, and the charm plans nothing. The workload stays as it is.
22+
- When all the checks pass, the charm plans the workload with `BYOSSO_ENABLED`, `SSO_SERVICE_GRPC_ADDRESS` and `KRATOS_PRIVILEGED_SESSION_MAX_AGE`.
23+
- The leader writes the field `byosso_enabled` in `ui-endpoint-info`. The value is the text `true` or the text `false`, as the option says. The leader does not write the field while a check fails.
24+
- The `login_ui_endpoints` library gets the field `byosso_enabled` (LIBPATCH 6).
25+
- The copy of the `kratos_info` library moves to LIBPATCH 7, which has `privileged_session_max_age`.
26+
- The gateway gets one more route, the exact path `/api/v0/sso/complete`.
27+
28+
These 4 parts of the change apply also while the option is off:
29+
30+
- The route `/api/v0/sso/complete` is on the gateway.
31+
- `ui-endpoint-info` has `byosso_enabled` as `false`.
32+
- The charm has the relation endpoint `sso-service-info`, and the Terraform module lists it. The charm does not use the address while the option is off.
33+
- The build of the charm needs `git`, because one dependency comes from a git repository.
34+
35+
The file of the `istio-public-route` specification gets a title, a `## Purpose` section and the `## Requirements` heading. The `openspec archive` command needs them before it can add a requirement to the file. The requirements that the file had do not change.
36+
37+
## Capabilities
38+
39+
### New Capabilities
40+
41+
- `bring-your-own-sso`: the option `byosso_enabled`, the checks of what the feature needs, the environment of the workload with the feature, and the field `byosso_enabled` of `ui-endpoint-info`.
42+
43+
### Modified Capabilities
44+
45+
- `istio-public-route`: one more route, the exact path `/api/v0/sso/complete`.
46+
47+
## Impact
48+
49+
- `charmcraft.yaml`: the option, the relation endpoint, and `git` in the build packages.
50+
- `pyproject.toml` and `uv.lock`: the package `sso-service-info`, at a commit of the repository of the SSO Service charm.
51+
- `src/charm.py`, `src/integrations.py`, `src/services.py`, `src/utils.py`, `src/constants.py`, and their unit tests.
52+
- `lib/charms/identity_platform_login_ui_operator/v0/login_ui_endpoints.py` (LIBPATCH 6).
53+
- `lib/charms/kratos/v0/kratos_info.py` (LIBPATCH 7).
54+
- `terraform/outputs.tf`: the endpoint `sso-service-info` in the `requires` output.
55+
- Other charms:
56+
- The feature needs a Kratos charm that writes `privileged_session_max_age` in `kratos-info`.
57+
- The charm relies on the Kratos charm to read `byosso_enabled` and to configure Kratos for the feature.
58+
- The feature needs a charm that provides `sso-service-info`.
59+
- A deployment that leaves the option off gets only the 4 parts of the list above.
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
## 1. Option and relation
2+
3+
- [x] 1.1 Add the boolean option `byosso_enabled`, default `false`, to `charmcraft.yaml`
4+
- [x] 1.2 Add the endpoint `sso-service-info` (interface `sso_service_info`, optional, limit 1) to `charmcraft.yaml`
5+
- [x] 1.3 Add `sso-service-info` to the `requires` output of the Terraform module
6+
- [x] 1.4 Add the package `sso-service-info` to `pyproject.toml`, at a commit of its repository, and update `uv.lock`
7+
- [x] 1.5 Add `git` to the build packages of the charm
8+
- [x] 1.6 Read `grpc_url` from `sso-service-info`, and handle the relation when it changes or breaks
9+
10+
## 2. Checks of the feature
11+
12+
- [x] 2.1 Read `privileged_session_max_age` from `kratos-info`, and update the `kratos_info` library to LIBPATCH 7
13+
- [x] 2.2 Make the 9 checks in order before each plan, and set the status of the first check that fails
14+
- [x] 2.3 Stop before the plan while a check fails
15+
16+
## 3. Workload
17+
18+
- [x] 3.1 Add `BYOSSO_ENABLED`, `SSO_SERVICE_GRPC_ADDRESS` and `KRATOS_PRIVILEGED_SESSION_MAX_AGE` to the environment when the feature is on
19+
20+
## 4. The field for Kratos
21+
22+
- [x] 4.1 Add the optional field `byosso_enabled` to the `login_ui_endpoints` library, LIBPATCH 6
23+
- [x] 4.2 Write `byosso_enabled` after each plan that succeeds
24+
- [x] 4.3 Write `byosso_enabled` with the endpoint URLs, but not while a check fails
25+
26+
## 5. Route
27+
28+
- [x] 5.1 Add the exact path `/api/v0/sso/complete` to the route `api-and-ui`
29+
30+
## 6. Unit tests
31+
32+
- [x] 6.1 Test the environment and the field `byosso_enabled` with the option on and with the option off
33+
- [x] 6.2 Test the status for each absent relation, for each relation without data, and for each Kratos check
34+
- [x] 6.3 Test that a check that fails adds no layer and leaves the field `byosso_enabled` unchanged
35+
- [x] 6.4 Test the field `byosso_enabled` for a new `ui-endpoint-info` relation
36+
- [x] 6.5 Test that the route configuration has the path `/api/v0/sso/complete`

0 commit comments

Comments
 (0)